Useful Git Commands
Follow the instructions to set up SSH key for Github.
View existing global configurations
$ git config --global --list
Set global configuration for user name and user email address.
$ git config --global user.name "<name of the user>"
$ git config --global user.email "<email address>"
Global Configurations are stored in ~/.gitconfig
Pull remote git repo
$ git clone <https/git url of the repo> <destination directory>
View the remote url
$ git remote -v
View remote references
$ git show-ref
Add all changes to local cache
$ git add .
If you want to undo changes to local repo
$ git reset
View the status
$ git status
Commit changes to the git local repo
$ git commit -m "A brief description of the change"
Push the change to remote location
$ git push origin master
Rebase the branch: put the local changes on top of the remote repo. It is a popular technique to merge the local and remote changes.
$ git stash
$ git pull --rebase
$ git stash pop
$ git add .; git commit -m "update"; git push origin HEAD
Git ignore the eclipse files
https://github.com/github/gitignore/blob/master/Global/Eclipse.gitignore
Adding git to an existing project and merge the existing components to current project.
$ git init
$ git remote add origin <git url, example: git@github.com:abulbasar/HadoopMRExamples.git>
$ git fetch
$ git merge origin/master
$ git remote -v
Overwrite local with remote copy
$ git fetch origin master
$ git reset --hard FETCH_HEAD
$ git clean -df