Git cheat sheet

Here’s a list of git commands that I’ve used to tackle different situations:

Rolling back tree to avoid complicated git pull conflicts

git reset --hard    # undo "git pull" which caused the conflicts
git reset HEAD~N    # rollback N commits
git checkout -f     # remove local files changes
git status          # check status; manually rm untracked files if necessary
git pull            # redo git pull

Combining and/or reordering patches

git rebase -i  HEAD~20   # interactively edit the last 20 patches

Detect file renames when creating patch

git-format-patch -4 -M   # the -M option ask git to detect renames

Creating a group-shareable repository for the first time

git-init --bare --shared=group   # read this for subsequent steps

That’s all for now!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: