My personal GIT Cheat Sheet

Refresh a local working branch copy from origin
$ git fetch --all
$ git reset --hard origin/master

Ignore given File in a Merge, e.g. defaults.php
$ git merge --no-commit
$ git reset HEAD myfile.txt
$ git checkout -- myfile.txt
$ git commit -m "merged "

Show history
$ git log -p -2
-p, which shows the difference introduced in each commit. You can also use -2, which limits the output to only the last two entries

Go back to a previous version indicated by commitHash
$ git reset --hard

Create a branch based off . Push the branch to remote repo
$ git checkout -b
$ git push --set-upstream origin

Ignore a file in Commit
$ git add -u
$ git reset --
$ git commit -am “Log message”

Remove Untracked files and directories
$ git clean -fd -n
“d” is used here for directories. “n” is used to list, and not Remove as yet
$ git clean -fd
Remove the files & directories

Show branches
$ git branch
Shows all local branches
$ git branch -r
Shows all remote branches
$ git branch -a
Shows all local & remote branches

Show files changed in a given Commit
$ git show --pretty=”” --name-only

Overwrite local commits, and take Remote as True copy
$ git fetch
$ git reset --hard origin/master  # remote branch which needs to be updated

Git ignore already checked in files
$ git update-index --assume-unchanged ...


Comments

Popular posts from this blog

504 Gateway Timeout on Amazon AWS ELB (Elastic Load Balancer)

AWS RDS incompatible-parameters solved

Push Notifications to iOS not received from Amazon SNS