@@ -128,6 +128,33 @@ git remote set-url origin <URL>
128
128
129
129
where the ` <URL> ` is your new fork.
130
130
131
+ ### I changed a submodule by accident
132
+
133
+ Usually people notice this when rustbot posts a comment on github that ` cargo ` has been modified:
134
+
135
+ ![ rustbot submodule comment] ( ./img/rustbot-submodules.png )
136
+
137
+ You might also notice conflicts in the web UI:
138
+
139
+ ![ conflict in src/tools/cargo] ( ./img/submodule-conflicts.png )
140
+
141
+ The most common cause is that you rebased after a change and ran ` git add . ` without first running
142
+ ` x.py ` to update the submodules. Alternatively, you might have run ` cargo fmt ` instead of ` x fmt `
143
+ and modified files in a submodule, then commited the changes.
144
+
145
+ To fix it, do the following things:
146
+
147
+ 1 . See which commit has the accidental changes: ` git log --stat -n1 src/tools/cargo `
148
+ 2 . Revert the changes to that commit: ` git checkout <my-commit>~ src/tools/cargo ` . Type ` ~ `
149
+ literally but replace ` <my-commit> ` with the output from step 1.
150
+ 3 . Tell git to commit the changes: ` git commit --fixup <my-commit> `
151
+ 4 . Repeat steps 1-3 for all the submodules you modified.
152
+ - If you modified the submodule in several different commits, you will need to repeat steps 1-3
153
+ for each commit you modified. You'll know when to stop when the ` git log ` command shows a commit
154
+ that's not authored by you.
155
+ 5 . Squash your changes into the existing commits: ` git rebase --autosquash -i upstream/master `
156
+ 6 . [ Push your changes] ( #standard-process ) .
157
+
131
158
### I see "error: cannot rebase" when I try to rebase
132
159
133
160
These are two common errors to see when rebasing:
0 commit comments