Skip to content

Instantly share code, notes, and snippets.

@yoterpa
Last active August 29, 2015 14:13
Show Gist options
  • Save yoterpa/1b62513db1323c63f09c to your computer and use it in GitHub Desktop.
Save yoterpa/1b62513db1323c63f09c to your computer and use it in GitHub Desktop.

Untrack Files

Just calling git rm --cached <filename> on each of the files you want to remove from revision control should be fine. As long as your local ignore patterns are correct you won't see these files included in the output of git status.

Note that this solution removes the files from the repository, so all developers would need to maintain their own local (non-revision controlled) copies of the file.

Show the name of branches in git log

git log --graph --all --decorate It annotates commits which are pointed to by tags or branches.

Delete a local branch

git branch -D bugfix
Deleted branch bugfix (was 2a14ef7).

Tagging

Creating an annotated tag in Git is simple. The easiest way is to specify -a when you run the tag command:

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

Another way to tag commits is with a lightweight tag. This is basically the commit checksum stored in a file – no other information is kept. To create a lightweight tag, don’t supply the -a, -s, or -m option:

git tag v1.4-lw

git tag
v0.1
v1.2
v1.3
v1.4
v1.4-lw
v1.5

git show

============ You can’t really check out a tag in Git, since they can’t be moved around. If you want to put a version of your repository in your working directory that looks like a specific tag, you can create a new branch at a specific tag:

git checkout -b version2 v2.0.0
Switched to a new branch 'version2'

Of course if you do this and do a commit, your version2 branch will be slightly different than your v2.0.0 tag since it will move forward with your new changes, so do be careful.

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