Skip to content

Instantly share code, notes, and snippets.

@ildyria
Created March 7, 2019 12:01
Show Gist options
  • Save ildyria/260c53f56cf2ac83d73d38b18394301f to your computer and use it in GitHub Desktop.
Save ildyria/260c53f56cf2ac83d73d38b18394301f to your computer and use it in GitHub Desktop.
# /bin/sh
echo "
list of commands that you might want to know
git add -A : add all files
git add --all : add all files
git add -u : update modified files
git commit -m <msg> : commit some changes with <msg>
git commit -am <msg> : git add -u + git commit -m
git mv <source> <destination> : move a file/folder
git status : check local status
git fetch : check for changes online
git pull : check for changes online and update local
git push : push your commited changes online
REVERT CHANGES :
git checkout -- <file> : reset your file/folder to the last commit
git stash : reset your local repo to the last commit
IN CASE OF CONFLICT :
git fetch --all
git reset --hard origin/master
/!\ your changes will be destroyed
TO MERGE IN CASE OF CONFLICT :
git fetch : parse the last modifications
git difftool : merge the files
Edit the files (chose the right parts), commit and push.
MORE ADVANCED STUFF :
git stash save <message> : save temporarly your changes and revert
git stash list : show the list of the previous \"stash\"
git stash clear : clear the previous list
git stash pop : return to your working state
BRANCHES
git checkout -b <branch name> : create a branch <branch name>
git checkout <branch name> : switch to branch <branch name>
git push -u --all
git checkout <commit number> : switch to this commit /!\ DANGEROUS
MERGE /!\ DANGEROUS
git merge <branch name> merges ROOT BRANCH (the one you are on, see git status) with <branch name>.
The changes are done on ROOT BRANCH.
alias gtree='git log --oneline --decorate --all --graph'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment