Project

General

Profile

Common git operations » History » Version 16

cryptogopher, 2020-07-10 02:47

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