Project

General

Profile

Common git operations » History » Version 16

cryptogopher, 2020-07-10 02:47

1 1 cryptogopher
h1. Common git operations
2
3 5 cryptogopher
{{>toc}}
4 1 cryptogopher
5
Prerequisites:
6
<pre>
7
cd ~/plugins/issue_recurring
8
</pre>
9
10 14 cryptogopher
h2. Issue/pull request resolution in separate branch
11 1 cryptogopher
12 2 cryptogopher
h3. Create separate branch for issue
13 3 cryptogopher
14 2 cryptogopher
# Checkout and update master:
15
<pre>
16
$ git checkout master
17
$ git pull
18
</pre>
19
# Create, checkout new branch and push it to remote (so it will be tracked and replicated on it.michalczyk.pro):
20
<pre>
21
$ git checkout -b issueN
22
$ git push -u origin issueN
23
</pre>
24 9 cryptogopher
# Reload all files open in vim:
25 7 cryptogopher
<pre>
26
:bufdo! e
27
</pre>
28
29 16 cryptogopher
h3. Checkout pull request locally (for editing, testing etc.)
30
31
# Fetch pull request based on its number into new branch and switch to new branch:
32
<pre>
33
$ git fetch origin pull/N/head:prN
34
$ git checkout prN
35
</pre>
36
# (optionally) Push newly created branch:
37
<pre>
38
git push -u origin prN
39
</pre>
40
41 13 cryptogopher
h3. Merge issue/pull request branch into master
42 2 cryptogopher
43
# Push uncommited changes on issue branch.
44 1 cryptogopher
# Checkout and update master:
45
<pre>
46
$ git checkout master
47
$ git pull
48
</pre>
49 13 cryptogopher
# Merge adding comment _closes #N_ (for issue branch), optionally view commits and push issueN/prN branch:
50 1 cryptogopher
<pre>
51
$ git merge issueN
52 13 cryptogopher
$ git log origin/master..HEAD
53 5 cryptogopher
$ git push
54 10 cryptogopher
</pre>
55
# Delete merged branch from local and remote:
56 11 cryptogopher
<pre>
57
$ git branch -d issueN
58 12 cryptogopher
$ git push origin :issueN
59
</pre>
60
# Verify:
61
<pre>
62
$ git branch -a
63
</pre>
64 11 cryptogopher
65
66 5 cryptogopher
h2. Release
67 4 cryptogopher
68
h3. Move tag to different commit (e.g. after fixing some mistake)
69
70
# Remove tag from remote (if it has been pushed):
71
<pre>
72
git push origin :refs/tags/1.3
73
</pre>
74
# Force replacement of existing tag with one referencing most recent commit:
75
<pre>
76
git tag -fa 1.3
77
</pre>
78
# Push:
79
<pre>
80
git push origin 1.3
81
</pre>