Git Basic Command List
Serial | Git Command | Description | Tags |
---|---|---|---|
1 | git init | Initialize git repository in a folder | init,start git,open git |
2 | git status | Information about changed/deleted files | status,condition,changes,modify |
3 | git config username.name Jhon | Config git user for the current git | git, config, user,name |
4 | git config username.email jhon@gmail.com | Config git email for the current git | git, config, user,email |
5 | git config --global username.name Jhon | Config git user for the current git globally in a machine | setup,config, globally, user,name |
6 | git config --global username.email jd@gmail.com | Config git email for the current git globally in a machine | setup,config, globally, user,email |
7 | git remote add origin https://github.com/arif98741/gitcom | Config remote connection for uploading files and data to the repository(such as github, gitlab, bitbucket, sourceforge) | setup,origin,remote,server,repo |
8 | git -v | Current installed git version | git,version,show |
9 | git add file.txt | Add specific file for commit | add, fixed, specific, custom file |
10 | git add . | Add all changed file for commit | add, all, every file, changed |
11 | git commit -m "commit message" | Commit Changes with messages and information | commit, change, -m |
12 | git branch | See all local branch list | branch, list, local |
13 | git branch -a | See all local and remote branch | branch,remote, list,all, local | 14 | git branch -r | See all remote branch list | remote,all, list,branch |
15 | git branch branch_name | Create new branch locally | branch, change, make, create |
16 | git checkout -b branch_name | Create new branch and move to there | create, move, branch, checkout |
17 |
git checkout -b branch_name or git push origin branch_name |
Create new branch locally and push it to origin | branch, change, make, create |
18 | git checkout dev | Migrate from any branch to dev | create, move, branch, checkout |
19 | git branch -D branch_name | Delete local branch | delete, local, branch, repo |
20 | git push --delete origin branch_name | Delete branch from remote | delete, origin, branch, checkout |
21 | git push | Push current changed commits to current branch where you are | push, commit, master |
22 | git push -u origin master | Push current changed commits to master branch | push, commit, change,master |
23 | git push -u origin branch_name | Push current changed commits to specific branch | specific,fixpush,branch,commit, change,master |
24 | git log | show all commits with details | git,log, change, commit,all |
25 | git log --oneline | show all commits with summary | log,change,commit,summary |
26 | git rev-list --all | show all commits with commit long id | git,log, change, commit,all |
27 | git rev-list --all --count | Show number of commits | count, number, how many, log |
28 | git shortlog | Show number of commits with summary | log,number,commit,list |
29 | git shortlog -s | Show number of commits per user | user,commit,change,log,list,count,number |
30 | git pull | update local branch by fetching data from remote origin | pull, update,remote ,origin |
31 | git tag | Show all local tag list | tag, list, all, tags |
32 | git ls-remote --tags origin | Show all remote tag list | tag, list,remote, origin, all, tags |
33 | git tag tag_name | Create a new tag locally | tag, create, new, local |
34 | git checkout tags/tagname | Checkout to new tag | tag, checkout, new, |
35 | git tag tag_name -a or git push origin --tags |
Create a local tag and upload to origin | origin, tag, remote |
36 | git push --tags | Push all tags to the remote | push, tag, all, --tags |
37 | git tag tag_name -a | Create a new tag with nesscessary description | -a, tag,create, make |
38 | git tag -d tag_name | Delete local tag | tag,delete,clear, local |
39 | git push origin :tagname or git push --delete origin tagname or git push origin :refs/tags/tagname |
Delete remote tag | tag, delete, push, origin |
40 | git fetch --tags | Fetch and update local tags from remote origin | tag,fetch,remote,origin |
41 | git merge feature | Merge master branch with feature sub brach | master,rebase, feature,sub, child |
42 | git rebase feature | Rebase feature branch with master branch | rebase, feature, master, merge, change |
43 | git push -u --all | Push Branch on Remote | push, branch, remote |
44 | git reset | Unstage All Added Before Commit Done | stage, unstage, git, commit |
45 | git reset --hard HEAD | Delete last commit and return to code | code, last, commit, code |
46 | git reset --soft HEAD | Delete commit and save changes | code, last, commit, change |
47 | git rm --cached filename | Remove specific file from git cache | cache, remove, git, fixed,file |
48 | git rm -r --cached . | Remove all files from git cache | cache,all,remove,files |
49 | git reset --hard HEAD~1 | Remove last commit from local | Remove last commit |
50 | git push -f origin master | Push change to remote | Push to remove |