Git Hacks and Tricks

From OPeNDAP Documentation
⧼opendap2-jumptonavigation⧽

Git resources

Setup a username and access token for GitHub

git config --global github.user <name>
git config --global github.token <token>
where the token is made using the instructions at https://help.github.com/articles/creating-an-access-token-for-command-line-use

When using an old version of git on Linux

[jimg@wasabi hyrax-git]$ git pull
error: Couldn't resolve host 'github.com' while accessing https://github.com/opendap/hyrax.git/info/refs

Cheat sheet items

These are simple things that are not really obvious from the git book or other sources

How to see a list of 'conflicted' files after a merge
git diff --name-only --diff-filter=U
How to see the different remote branches
git remote show origin
How do I see what would be pushed to a remote repo?
git push --dry-run
git diff origin/master # Assumes you have run git fetch, I think
git diff --stat origin/master # --stat just shows the file names stats, not the diffs
To get a specific file from a specific branch
git show dap4:./gdal_dds.cc > gdal_dds.dap4.cc You can use checkout instead of show and that will overwrite the file.
the general syntax is object (that's the 'dap4:./gdal_dds.cc' part) and it can use the ^ and ~n syntax to specify various commits on the given branch. A SHA can also be used.
How to change the 'origin' for a remote repo
git remote set-url origin git://new.url.here (https URLs work too...)
How to push a local branch to a remote repo
git push -u origin feature_branch_name
How to make and track a new (local) branch
git checkout -b <branch name>