Yet Another Blog

Rambler, Developer and gamer

Git Cheat Sheet

| Comments

Git commands that I always forget but find useful:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Recover a file:
git checkout <previous-commit-hash> <file_path>`

# Ignore changes to certain files:
git update-index --assume-unchanged config/database.yml

# Take commit from another branch:
git cherry-pick <commit reference>

# Delete multiple branches starting with some string:
git branch -D `git for-each-ref --format="%(refname:short)" refs/heads/some_string\*`

# List branches in order of which most recent commit
git for-each-ref --sort=-committerdate refs/heads/

I tend to alias things so when on another machine it’s handy!

Comments