aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cheatsheet.txt99
1 files changed, 99 insertions, 0 deletions
diff --git a/cheatsheet.txt b/cheatsheet.txt
new file mode 100644
index 0000000..92bee2e
--- /dev/null
+++ b/cheatsheet.txt
@@ -0,0 +1,99 @@
+Tag
+
+ git tag -a x.y.z -m "Tag version x.y.z"
+
+Squash multiple commits into one
+
+ git rebase -i HEAD~<N>
+
+ http://www.gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
+
+Change commit message
+
+ git commit --amend
+
+Revert uncommited changes
+
+ git reset --hard HEAD
+
+Copy commit from one branch to the other
+
+ # On the source branch
+ git log -1
+ git cout <target-branch>
+ git cherry-pick <commit-id>
+
+Setup remote repository
+
+ On remote:
+
+ 1. Use the server/mkrepo.sh script:
+
+ mkdrepo.sh <name>
+ mkdrepo.sh --private <name>
+
+ <name> is without the .git suffix.
+
+ On local:
+
+ 1. git remote add origin scm.codesynthesis.com:/var/scm/proj/proj.git
+ 2. git push --tags origin master
+ 3. # blow the local project and do clone
+ git clone scm.codesynthesis.com:/var/scm/proj/proj.git [name]
+
+Delete a branch from a remote repository
+
+ git push origin :experimental
+
+ Find a ref that matches experimental in the origin repository (e.g.
+ refs/heads/experimental), and delete it.
+
+ Using the push.sh script:
+
+ ./push.sh :<name>
+
+Rebasing
+
+ Local (e.g., from a feature branch to master):
+
+ git rebase <src> [<dst>]
+
+ If <dst> is not specified, current branch is used. If <dst> is
+ specified, it is checked out.
+
+ Remote (e.g., merge someone else's changes):
+
+ git fetch
+ git rebase origin[/master]
+ git push --tags origin
+
+Submodules
+
+ git config --global status.submoduleSummary true
+ git config --global diff.submodule log
+
+ git submodule update --init # init and update
+ git clone --recursive # same as doing above manually
+
+ git submodule update --remote [sub] # update submodule(s) (to remote master)
+ # --rebase
+
+ git fetch
+ git checkout <commit-sha1> # As above but to specific commit.
+
+ git pull # fetches submodules, but does not update
+ git submodule update # must be done explicitly (--init --recursive)!
+
+ # Making changes, first make sure up-to-date with remote
+ #
+ git cout master # in submodule, to make changes, commit/push must be on both!
+
+ # If already made changes (in sub/):
+ git stash
+ git cout master
+ git stash pop
+
+ # Remove submodule.
+ #
+ git submodule deinit sub
+ git rm sub # then commit