FAQ Style Article

GIT cheat sheet

This article shows how GIT can be used to do common version control tasks

Remove untracked files
(a) Remove files
git clean -f
(b) Remove files and directories
git clean -f -d

Push local branche(s) to remote repository
(a) Push all branches
git push origin --all
(b) Push named branch
git push origin <branch name>

Change commit message
(a) Last commit
git commit --amend -m "New commit message"

Delete last commit
(a) Committed but not pushed upstream yet
git reset --soft HEAD~1

Update local repo with remote, but not merge
git fetch

Update local repo with remote and merge
git pull

Stash current work and pop it back
(a) Stash the current work
git stash
(b) Restore the stashed work
git stash pop

Change previous commits
git commit --fixup <commit_id_to_amend> <file>
git rebase -i --autosquash

Remove last commit
git reset --hard HEAD^

Add all modified and removed tracked files to staging area
git add -u

Resources
(a) GIT Sheet

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: