/

Git

cheatsheet
Table of contents
  • Branches
  • Generate release notes
  • Tags

Branches

List all local branches

sh
git branch

List all merged branches

sh
git branch --merged

Same as above but exclude master and develop branches

sh
git branch --merged | egrep -v "(^\*|master|develop)"

Deleting branches

sh
git branch -d branch_name

Delete remote branches

sh
git push origin --delete branch1 branch2

Generate release notes

These release notes were generated using this script:

sh
git log f5b38145...8c17d7a9 --pretty=format:'- **%s** ([%h](github.com/mrmartineau/notes.zander.wtf/commit/%H)) by %an' --reverse

To retrieve the git commit hashes use this:

sh
git log --oneline

Tags

sh
# list all git tags
git tag -l
git tag --list
# create a git tag
git tag v1.9.2
# remove a git tag
git tag -d v1.9.2
git tag --delete v1.9.2
# push all tags to remote
git push --follow-tags origin master

gitsheet.wtf

gitexplorer.com

Setting Up Git Identities

Branching strategies

GitHub flow

  • Anything in the master branch is deployable
  • To work on something new, create a descriptively named branch off of master (ie: new-oauth2-scopes)
  • Commit to that branch locally and regularly push your work to the same named branch on the server
  • When you need feedback or help, or you think the branch is ready for merging, open a pull request
  • After someone else has reviewed and signed off on the feature, you can merge it into master
  • Once it is merged and pushed to ‘master’, you can and should deploy immediately
Want to make your own site like this? Try gatsby-theme-code-notes by Zander Martineau.
Notes on code. My second brain, by Zander Martineau.