Skip to content

Instantly share code, notes, and snippets.

@Vic-ST
Last active March 7, 2017 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vic-ST/a221c77e733f27f7c09b6d587c040e27 to your computer and use it in GitHub Desktop.
Save Vic-ST/a221c77e733f27f7c09b6d587c040e27 to your computer and use it in GitHub Desktop.
Git cheat sheet
Git cheat sheet:
Commands:
git log
git show HEAD
git commit -m "(Text)"
git branch
git status
git add filename
git diff filename
git checkout HEAD filename
git reset HEAD filename
git reset SHA
git branch new_branch
git checkout branch_name
git merge branch_name
git branch -d branch_name
git clone remote_location clone_name
git remote -v
git fetch
git merge origin/master
git push orgin your_branch_name
Explain:
git log shows a log of the commits
git show HEAD shows the most recent commit
git commit -m "" adds a commit(you can look at all of the commits by typing git log)
git branch shows what branch you are on
git add filename adds a file to the staging area
git diff filename shows the difference in the file
git checkout HEAD restores the file to what it looked like before
git reset HEAD filename unstages that file from the staging area
git reset SHA rewinds to the part before you made the mistake
git branch new_branch adds a new branch
git checkout branch_name switches to that branch
git merge branch_name puts two branches together
get branch -d branch_name deletes the branch
git clone remote_location clone_name makes a new file
git remote -v lists all the remote files
git fetch checks if the file has a change
git merge origin/master ingrates origin/master into master branch
git push orgin your_name_branch pushes your branch remote
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment