Difference between revisions of "Git"
From Useful Things
| (3 intermediate revisions by the same user not shown) | |||
| Line 14: | Line 14: | ||
</pre> | </pre> | ||
where <code>remote-name</code> is usually something like <code>origin</code> | where <code>remote-name</code> is usually something like <code>origin</code> | ||
| + | |||
| + | == Checkout remote branch and set it up for tracking == | ||
| + | Note: These instructions are specific to having cloned in this manner: <code>git clone -b <branch-name> --single-branch</code> as it only tracks the branch chosen at clone time. | ||
| + | <pre> | ||
| + | git fetch origin <branch-name> | ||
| + | </pre> | ||
| + | |||
| + | <pre> | ||
| + | git remote set-branches origin <branch-name> | ||
| + | </pre> | ||
| + | |||
| + | == Show contents of merge commit == | ||
| + | <pre> | ||
| + | git show -m [SHA1] | ||
| + | </pre> | ||
| + | where <code>-m</code> means maximum verbosity, automatically implied only with non-merge commits | ||
| + | |||
| + | == View pretty git history on the console == | ||
| + | <pre> | ||
| + | git config --global alias.lol "log --oneline --graph --decorate" | ||
| + | </pre> | ||
| + | <pre> | ||
| + | git lol | ||
| + | </pre> | ||
| + | |||
| + | == Cache CLI credentials for a certain period of time == | ||
| + | <pre> | ||
| + | git config --global credential.helper cache | ||
| + | git config --global credential.helper 'cache --timeout=86400' | ||
| + | </pre> | ||
Latest revision as of 05:03, 25 May 2015
Contents
Undo last commit and KEEP changes
git reset --soft HEAD~1
Undo last commit and LOSE changes
git reset --hard HEAD~1
List all remote branches
git ls-remote --heads <remote-name>
where remote-name is usually something like origin
Checkout remote branch and set it up for tracking
Note: These instructions are specific to having cloned in this manner: git clone -b <branch-name> --single-branch as it only tracks the branch chosen at clone time.
git fetch origin <branch-name>
git remote set-branches origin <branch-name>
Show contents of merge commit
git show -m [SHA1]
where -m means maximum verbosity, automatically implied only with non-merge commits
View pretty git history on the console
git config --global alias.lol "log --oneline --graph --decorate"
git lol
Cache CLI credentials for a certain period of time
git config --global credential.helper cache git config --global credential.helper 'cache --timeout=86400'