Project

General

Profile

Common git operations » History » Version 14

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 13 cryptogopher
h3. Merge issue/pull request branch into master
30 2 cryptogopher
31 2 cryptogopher
# Push uncommited changes on issue branch.
32 1 cryptogopher
# Checkout and update master:
33 1 cryptogopher
<pre>
34 1 cryptogopher
$ git checkout master
35 1 cryptogopher
$ git pull
36 1 cryptogopher
</pre>
37 13 cryptogopher
# Merge adding comment _closes #N_ (for issue branch), optionally view commits and push issueN/prN branch:
38 1 cryptogopher
<pre>
39 1 cryptogopher
$ git merge issueN
40 13 cryptogopher
$ git log origin/master..HEAD
41 1 cryptogopher
$ git push
42 1 cryptogopher
</pre>
43 1 cryptogopher
# Delete merged branch from local and remote:
44 1 cryptogopher
<pre>
45 1 cryptogopher
$ git branch -d issueN
46 1 cryptogopher
$ git push origin :issueN
47 1 cryptogopher
</pre>
48 1 cryptogopher
# Verify:
49 1 cryptogopher
<pre>
50 1 cryptogopher
$ git branch -a
51 1 cryptogopher
</pre>
52 5 cryptogopher
53 10 cryptogopher
h2. Pull requests
54 10 cryptogopher
55 10 cryptogopher
h3. Checkout pull request locally (for editing, testing etc.)
56 10 cryptogopher
57 11 cryptogopher
# Fetch pull request based on its number into new branch and switch to new branch:
58 11 cryptogopher
<pre>
59 12 cryptogopher
$ git fetch origin pull/N/head:prN
60 12 cryptogopher
$ git checkout prN
61 12 cryptogopher
</pre>
62 12 cryptogopher
# (optionally) Push newly created branch:
63 12 cryptogopher
<pre>
64 12 cryptogopher
git push -u origin prN
65 11 cryptogopher
</pre>
66 11 cryptogopher
67 5 cryptogopher
h2. Release
68 4 cryptogopher
69 4 cryptogopher
h3. Move tag to different commit (e.g. after fixing some mistake)
70 4 cryptogopher
71 4 cryptogopher
# Remove tag from remote (if it has been pushed):
72 4 cryptogopher
<pre>
73 4 cryptogopher
git push origin :refs/tags/1.3
74 4 cryptogopher
</pre>
75 4 cryptogopher
# Force replacement of existing tag with one referencing most recent commit:
76 4 cryptogopher
<pre>
77 4 cryptogopher
git tag -fa 1.3
78 4 cryptogopher
</pre>
79 4 cryptogopher
# Push:
80 4 cryptogopher
<pre>
81 4 cryptogopher
git push origin 1.3
82 4 cryptogopher
</pre>