Git commands cheat sheet:
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
In the last blog post, we have discussed git remote repository.
https://cloudaffaire.com/git-remote-repository/
We are almost done with our introductory series on Git. In this blog post, we will list all the commands that have been used so far in this series.
Git commands cheat sheet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
##------------------------------ ## Git Commands Cheat Sheet ## ##------------------------------ ## Check git version git version ## Initialize git local repository git init ## Initialize git local repository with directory git init ## Check git status git status ## Getting help from command line git help ## List all git commands and sub-commands git help -a ## Getting help for a particular git command git help ## Add a file in staging area git add ## Add all in staging git add . ## Commit a change git commit -m " ## Get difference between staging area in working tree git diff ## Get difference between local repository and staging git diff --stage ## Check the log git log --oneline ## Get the logs git log --all --decorate --oneline --graph ## Create a alias for above command alias graph="git log --all --decorate --oneline --graph" ## Check logs git reflog ## Discard the change in working tree git checkout -- ## Discard changes in staging area git reset HEAD ## Restore the file file1 from local repository (file1 will be restored to working tree and staging area) git checkout ## Add your user name and email to git config git config --local user.name "Debjeet" git config --local user.email "debjeettoni@gmail.com" ## Create a branch git branch ## List all branches git branch ## Switch to another branch git checkout ## Check difference between two branches git diff ## Merge two branches git merge ## Check which branch are merged with which one git branch --merged ## Delete a branch git branch -d ## Rename current branch git branch -m ## Git rebase git rebase ## Edit the last commit message git commit --amend ## Edit multiple commits git rebase -i HEAD~4 ## Clone the remote repository git clone https://github.com/CloudAffaire/mygit.git ## Add remote repository to existing local repository git remote add origin https://github.com/CloudAffaire/mygit.git ## Check remote repository git remote -v ## Push the changes to remote repository git push ## Push a particular branch from local repo to remote repo git push --set-upstream origin ## Pull the changes from remote repository git pull ## Pull a branch from remote repo to local repo git pull origin ## Delete a remote repo branch git push origin --delete |
To get more details on git, please refer below git documentation