The Wonder of GIT

Setup your identity:

git config --global "FirstName LastName"
git config --global ""

Make git a little prettier:

git config --global color.ui "auto"

The basic format of the push operation is:

git push $repository-location $source-branch:$dest-branch

Publish a local branch, remotely:

git push origin $local-branch:$remote-branch

Delete a remote branch:

git push origin :$remote-ref

Once a remote branch is deleted, other team members must delete references to the deleted branches by running:

git remote prune origin

Create a local branch to track a remote branch:

git branch --track local-branch-2 origin/remote-branch-2

Work on a remote branch other than master

git fetch // to ensure git local knows about remote branch
git checkout --track -b $local-branch origin/$remote-branch

To find some code you previously had in a file

// Find the relevant commit
git log /path/to/file
// Now view the changes in that file since that particular commit
git diff $commitHash /path/to/file

To revert just one file to a previous commit
git checkout $commitHASH /path/to/file

To see who is responsible for the current state of a particular file:

git blame $fileName



Popular posts from this blog

Android: How to change size of vector drawable image

AngularJs: User friendly date display with AngularJs and MomentJs

Nerd Tree: A File Explorer with Mac Vim