Skip to content

Commit 4663f85

Browse files
jyn514Joshua Nelson
authored andcommitted
Add information about common git issues
1 parent ad67023 commit 4663f85

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

src/git.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,55 @@ the same, with some steps skipped:
7373
2. Make, stage, and commit your additional changes just like before.
7474
3. Push those changes to your fork: `git push`.
7575

76+
## Troubleshooting git issues
77+
78+
You don't need to clone `rust-lang/rust` from scratch if it's out of date!
79+
Even if you think you've messed it up beyond repair, there are ways to fix
80+
the git state that don't require downloading the whole repository again.
81+
Here are some common issues you might run into:
82+
83+
### I deleted my fork on GitHub!
84+
85+
This is not a problem from git's perspective. If you run `git remote -v`,
86+
it will say something like this:
87+
88+
```
89+
$ git remote -v
90+
origin https://github.com//rust-lang/rust (fetch)
91+
origin https://github.com//rust-lang/rust (push)
92+
personal https://github.com/jyn514/rust (fetch)
93+
personal https://github.com/jyn514/rust (push)
94+
```
95+
96+
You can change the URL of the fork like this:
97+
98+
```console
99+
git remote set-url personal <URL>
100+
```
101+
102+
where the <URL> is your new fork.
103+
104+
### I see 'Untracked Files: src/stdarch'?
105+
106+
This is left over from the move to the `library/` directory.
107+
Unfortunately, `git rebase` does not follow renames for submodules, so you
108+
have to delete the directory yourself:
109+
110+
```console
111+
rm -r src/stdarch
112+
```
113+
114+
### I see `<<< HEAD`?
115+
116+
You were probably in the middle of a rebase or merge conflict. See
117+
[Conflicts](#conflicts) for how to fix the conflict. If you don't care about the changes
118+
and just want to get a clean copy of the repository back, you can use `git reset`:
119+
120+
```console
121+
# WARNING: this throws out any local changes you've made! Consider resolving the conflicts instead.
122+
git reset --hard master
123+
```
124+
76125
### Quick note about submodules
77126

78127
When updating your local repository with `git pull`, you may notice that sometimes
@@ -94,7 +143,7 @@ no changes added to commit (use "git add" and/or "git commit -a")
94143
```
95144

96145
These changes are not changes to files: they are changes to submodules
97-
(more on this later). To get rid of those, run `git submodule update` (or run any
146+
(more on this [later](#git-submodules)). To get rid of those, run `git submodule update` (or run any
98147
`x.py` command, which will automatically update the submodules).
99148
Note that there is currently a bug if you use worktrees, submodules, and x.py in a commit hook.
100149
If you run into an error like:

0 commit comments

Comments
 (0)