Collection of useful git snippets
This is just a bunch of git
related snippets. Collected from around the internet.
git clean -fn
git branch --set-upstream BRANCH ANOTHER_BRANCH
git rm -r --cached .
git add .
git commit -m "fix .gitignore"
git reset HEAD FILENAME
git checkout -- FILENAME
To unstage changes
git reset HEAD~1
To completely undo
git reset --hard HEAD~1
git checkout -b NEW_BRANCH
git push --set-upstream ORIGIN NEW_BRANCH
git merge --abort
git log --cherry-mark --oneline A_BRANCH..ANOTHER_BRANCH
git diff-tree --no-commit-id --name-only -r THE_COMMIT_ID
git shortlog -sn --all --no-merges
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
if ORIGIN
is the remote repository, and MASTER
the remote branch.
git pull ORIGIN MASTER
history | grep git
git clean -f -d
if ORIGIN
is the remote repository, and MASTER
the remote branch.
git branch -u ORIGIN/MASTER
git grep 'STRING'
git log --author 'AUTHOR'
MIT