Skip to content

Commit f2ebffb

Browse files
authored
git-terminal.md: add commands to update a fork and change email (#5956)
1 parent d86d3d6 commit f2ebffb

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

contributing-guides/git-terminal.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Opening a Pull Request
2+
13
Most people submit pull requests to the tldr-pages project
24
[using GitHub's web interface][pr-howto].
35

@@ -29,3 +31,57 @@ Typically a pull request will include changes in a single file.
2931
[pr-howto]: ../CONTRIBUTING.md#submitting-a-pull-request
3032
[commit-msg]: ../CONTRIBUTING.md#commit-message
3133
[mass-changes]: https://github.com/tldr-pages/tldr/pulls?&q=is:pr+is:merged+label:"mass+changes"
34+
35+
# Updating your fork
36+
37+
Forks of GitHub repositories aren't updated automatically. To keep your fork up-to-date with the latest changes and avoid merge conflicts, you should update it regularly.
38+
39+
There are two ways to update your fork.
40+
41+
1. Via the GitHub web interface. Click `Fetch upstream` and then `Fetch and merge` on the fork as shown below:
42+
43+
![Fetch and merge button in GitHub](../images/github-fetch-and-merge-button.png).
44+
45+
2. Using Git in the terminal:
46+
47+
```bash
48+
git checkout main
49+
git remote add upstream https://github.com/tldr-pages/tldr.git # only run if you don't already have the upstream remote (check with "git remote -v")
50+
git fetch upstream main
51+
git rebase upstream/main # in case you have any merge conflicts, click the link below to see how to resolve them
52+
git push --force-with-lease # not needed if you only want to update your local repository
53+
```
54+
[How to resolve merge conficts](https://docs.github.com/en/github/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line)
55+
56+
# Changing the email of your last commit
57+
58+
If the email that you used for the last commit isn't associated with your GitHub account, you can either add it [here](https://github.com/settings/emails) or change the email of the commit with the following commands:
59+
60+
```bash
61+
git commit --amend --author="Your Name <[email protected]>"
62+
git push --force-with-lease
63+
```
64+
65+
# Changing the email of any commit(s)
66+
67+
Let's take this commit history as an example:
68+
69+
| Commit Hash | Author Email
70+
|---|---
71+
72+
73+
74+
75+
76+
| F (HEAD) | [email protected]
77+
78+
To change the email of commts A and D, run
79+
80+
```bash
81+
git reset A
82+
git commit --amend --author="Your Name <[email protected]>"
83+
git cherry-pick B^..D # re-apply commits B to D
84+
git commit --amend --author="Your Name <[email protected]>"
85+
git cherry-pick E^..HEAD
86+
git push --force-with-lease
87+
```
38.8 KB
Loading

0 commit comments

Comments
 (0)