Common git operations » History » Version 18
cryptogopher, 2022-09-16 00:03
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 | 17 | cryptogopher | "Github docs":https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/checking-out-pull-requests-locally#modifying-an-inactive-pull-request-locally |
32 | 17 | cryptogopher | |
33 | 16 | cryptogopher | # Fetch pull request based on its number into new branch and switch to new branch: |
34 | 16 | cryptogopher | <pre> |
35 | 16 | cryptogopher | $ git fetch origin pull/N/head:prN |
36 | 16 | cryptogopher | $ git checkout prN |
37 | 16 | cryptogopher | </pre> |
38 | 16 | cryptogopher | # (optionally) Push newly created branch: |
39 | 16 | cryptogopher | <pre> |
40 | 16 | cryptogopher | git push -u origin prN |
41 | 16 | cryptogopher | </pre> |
42 | 16 | cryptogopher | |
43 | 13 | cryptogopher | h3. Merge issue/pull request branch into master |
44 | 2 | cryptogopher | |
45 | 2 | cryptogopher | # Push uncommited changes on issue branch. |
46 | 1 | cryptogopher | # Checkout and update master: |
47 | 1 | cryptogopher | <pre> |
48 | 1 | cryptogopher | $ git checkout master |
49 | 1 | cryptogopher | $ git pull |
50 | 1 | cryptogopher | </pre> |
51 | 13 | cryptogopher | # Merge adding comment _closes #N_ (for issue branch), optionally view commits and push issueN/prN branch: |
52 | 1 | cryptogopher | <pre> |
53 | 1 | cryptogopher | $ git merge issueN |
54 | 13 | cryptogopher | $ git log origin/master..HEAD |
55 | 5 | cryptogopher | $ git push |
56 | 10 | cryptogopher | </pre> |
57 | 10 | cryptogopher | # Delete merged branch from local and remote: |
58 | 11 | cryptogopher | <pre> |
59 | 11 | cryptogopher | $ git branch -d issueN |
60 | 12 | cryptogopher | $ git push origin :issueN |
61 | 12 | cryptogopher | </pre> |
62 | 12 | cryptogopher | # Verify: |
63 | 12 | cryptogopher | <pre> |
64 | 12 | cryptogopher | $ git branch -a |
65 | 12 | cryptogopher | </pre> |
66 | 11 | cryptogopher | |
67 | 11 | cryptogopher | |
68 | 5 | cryptogopher | h2. Release |
69 | 4 | cryptogopher | |
70 | 4 | cryptogopher | h3. Move tag to different commit (e.g. after fixing some mistake) |
71 | 4 | cryptogopher | |
72 | 4 | cryptogopher | # Remove tag from remote (if it has been pushed): |
73 | 4 | cryptogopher | <pre> |
74 | 4 | cryptogopher | git push origin :refs/tags/1.3 |
75 | 4 | cryptogopher | </pre> |
76 | 4 | cryptogopher | # Force replacement of existing tag with one referencing most recent commit: |
77 | 4 | cryptogopher | <pre> |
78 | 4 | cryptogopher | git tag -fa 1.3 |
79 | 4 | cryptogopher | </pre> |
80 | 4 | cryptogopher | # Push: |
81 | 4 | cryptogopher | <pre> |
82 | 4 | cryptogopher | git push origin 1.3 |
83 | 4 | cryptogopher | </pre> |
84 | 18 | cryptogopher | |
85 | 18 | cryptogopher | |
86 | 18 | cryptogopher | h2. Other |
87 | 18 | cryptogopher | |
88 | 18 | cryptogopher | h3. Change remote URL from HTTPS to SSH (required by Github's no-password policy) |
89 | 18 | cryptogopher | |
90 | 18 | cryptogopher | # Check current URL: |
91 | 18 | cryptogopher | <pre> |
92 | 18 | cryptogopher | git remote -v |
93 | 18 | cryptogopher | </pre> |
94 | 18 | cryptogopher | # Change to SSH: |
95 | 18 | cryptogopher | <pre> |
96 | 18 | cryptogopher | git remote set-url origin git@github.com:cryptogopher/issue_recurring.git |
97 | 18 | cryptogopher | </pre> |