Skip to content

Instantly share code, notes, and snippets.

@jonkemp
Last active August 29, 2015 13:56
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 jonkemp/9085932 to your computer and use it in GitHub Desktop.
Save jonkemp/9085932 to your computer and use it in GitHub Desktop.
Tips for using Git.

Tips for using Git

Tagging

Listing your tags

$ git tag

Creating Tags

Annotated

$ git tag -a v1.4 -m 'my version 1.4'

Sharing Tags

$ git push origin v1.5

Transfer multiple tags at once

$ git push origin --tags

Source: [http://git-scm.com/book/en/Git-Basics-Tagging]

Removing a Tag

$ git tag -d release01

$ git push origin :refs/tags/release01

Source: [https://confluence.atlassian.com/pages/viewpage.action?pageId=282175551]

Squashing Commits

Using Rebase

Squash the last 4 commits

$ git rebase -i HEAD~4

The next screen shows the commits that are being squashed. Here you tell it which commits to squash.

The second screen lets you modify the final commit message.

Source: [http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html]

Using git-merge

Apparently, there is a --squash flag for git-merge.

Source: [https://medium.com/code-adventures/a940ee20862d]

Rebasing Merge Commits in Git

$ git pull --rebase

Get rid of the empty merge commit.

Source: [http://notes.envato.com/developers/rebasing-merge-commits-in-git/]

Closing and Referencing Tickets

When you commit with a string like “Closes #123" GitHub sees this and will actually close the issue for you, along with referencing the commit in the issue.

The same goes for referencing, just place “#123" in the commit message or body.

Source: [https://medium.com/code-adventures/a940ee20862d]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment