GIT Cheatsheet
Checkout
- Grab file from another branch:
git checkout [branch-name] -- [file-name]
Tracking
- Track existing remote branch:
git checkout --track origin/dev
- Push new branch with tracking:
git push -u origin dev
Undo commits
- Undo last commit and put in staging
git reset --soft HEAD~1
Branch Activity
- Branch activity by date
for k in `git branch | sed s/^..//`; do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k --`\\t"$k";done | sort
Git tagging
Note: if the tag is part of a build process for versioning, tag locally...push tag to remote...then push branch
- Create annotated tag
git tag -a v1.0.0 -m "version 1.0.0"
- Delete a tag
git tag -d v1.0.0
- Push tag to remote
git push upstream v1.0.0