summaryrefslogtreecommitdiff
path: root/git/git-cheatsheet.txt
blob: 47372c5b1d4df935c3c77440fdfe2658be1e88a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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. mkdir proj.git
  2. chgrp scm proj.git  
  2. cd proj.git
  3. git --bare init --shared=all
  4. chgrp -R scm ../proj.git
  5. edit description
  6. cd hooks
  7. mv post-update.sample post-update

  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