@@ -16,6 +16,10 @@ started sections of [this tutorial from Atlassian][atlassian-git]. GitHub also
16
16
provides [ documentation] and [ guides] for beginners, or you can consult the
17
17
more in depth [ book from Git] .
18
18
19
+ This guide is incomplete. If you run into trouble with git that this page doesn't help with,
20
+ please [ open an issue] so we can document how to fix it.
21
+
22
+ [ open an issue ] : https://github.com/rust-lang/rustc-dev-guide/issues/new
19
23
[ book from Git ] : https://git-scm.com/book/en/v2/
20
24
[ atlassian-git ] : https://www.atlassian.com/git/tutorials/what-is-version-control
21
25
[ documentation ] : https://docs.github.com/en/get-started/quickstart/set-up-git
@@ -58,7 +62,7 @@ and PRs:
58
62
1 . Ensure that you're making your changes on top of master:
59
63
` git checkout master ` .
60
64
2 . Get the latest changes from the Rust repo: ` git pull upstream master --ff-only ` .
61
- (see [ No-Merge Policy] ( #keeping-things-up-to-date ) for more info about this).
65
+ (see [ No-Merge Policy] [ no-merge-policy ] for more info about this).
62
66
3 . Make a new branch for your change: ` git checkout -b issue-12345-fix ` .
63
67
4 . Make some changes to the repo and test them.
64
68
5 . Stage your changes via ` git add src/changed/file.rs src/another/change.rs `
@@ -76,7 +80,7 @@ pulling-and-rebasing, you can use `git push --force-with-lease`).
76
80
77
81
If you end up needing to rebase and are hitting conflicts, see [ Rebasing] ( #rebasing ) .
78
82
If you want to track upstream while working on long-running feature/issue, see
79
- [ Keeping things up to date] ( #keeping-things-up-to-date ) .
83
+ [ Keeping things up to date] [ no-merge-policy ] .
80
84
81
85
If your reviewer requests changes, the procedure for those changes looks much
82
86
the same, with some steps skipped:
@@ -86,13 +90,23 @@ the same, with some steps skipped:
86
90
2 . Make, stage, and commit your additional changes just like before.
87
91
3 . Push those changes to your fork: ` git push ` .
88
92
93
+ [ no-merge-policy ] : #keeping-things-up-to-date
94
+
89
95
## Troubleshooting git issues
90
96
91
97
You don't need to clone ` rust-lang/rust ` from scratch if it's out of date!
92
98
Even if you think you've messed it up beyond repair, there are ways to fix
93
99
the git state that don't require downloading the whole repository again.
94
100
Here are some common issues you might run into:
95
101
102
+ ### I made a merge commit by accident.
103
+
104
+ Git has two ways to update your branch with the newest changes: merging and rebasing.
105
+ Rust [ uses rebasing] [ no-merge-policy ] . If you make a merge commit, it's not too hard to fix:
106
+ ` git rebase -i origin/master ` .
107
+
108
+ See [ Rebasing] [ #rebasing ] for more about rebasing.
109
+
96
110
### I deleted my fork on GitHub!
97
111
98
112
This is not a problem from git's perspective. If you run ` git remote -v ` ,
@@ -114,6 +128,31 @@ git remote set-url personal <URL>
114
128
115
129
where the ` <URL> ` is your new fork.
116
130
131
+ ### I see "error: cannot rebase" when I try to rebase
132
+
133
+ These are two common errors to see when rebasing:
134
+ ```
135
+ error: cannot rebase: Your index contains uncommitted changes.
136
+ error: Please commit or stash them.
137
+ ```
138
+ ```
139
+ error: cannot rebase: You have unstaged changes.
140
+ error: Please commit or stash them.
141
+ ```
142
+
143
+ (See https://git-scm.com/book/en/v2/Getting-Started-What-is-Git%3F#_the_three_states for the difference between the two.)
144
+
145
+ This means you have made changes since the last time you made a commit. To be able to rebase, either
146
+ commit your changes, or make a temporary commit called a "stash" to have them still not be commited
147
+ when you finish rebasing. You may want to configure git to make this "stash" automatically, which
148
+ will prevent the "cannot rebase" error in nearly all cases:
149
+
150
+ ```
151
+ git config --global rebase.autostash true
152
+ ```
153
+
154
+ See https://git-scm.com/book/en/v2/Git-Tools-Stashing-and-Cleaning for more info about stashing.
155
+
117
156
### I see 'Untracked Files: src/stdarch'?
118
157
119
158
This is left over from the move to the ` library/ ` directory.
0 commit comments