forked from freebsd/freebsd-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGit.merge.upstream.changes.txt
72 lines (45 loc) · 2.36 KB
/
Git.merge.upstream.changes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
what to do, when your forked repository is behind the original repository?
Clone your fork:
#git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git
#cd into/cloned/fork-repo
Add remote from original repository in your forked repository:
#git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
#git fetch upstream
Updating your fork from original repo to keep up with their changes:
#git pull upstream master
#git push
Note:
Master : corresponds to branch name
Troubleshoot known problems:
(source: https://saywebsolutions.com/blog/git-github-error-fatal-couldnt-find-remote-ref-master)
The Problem
If you encounter the following error on a recently created github project when trying to pull from the default branch:
fatal: Couldn't find remote ref master
it's probably because you have tried to use the old racist command:
git pull origin master
The default git branch name master has recently been found to be racist, so it's been changed to default to main instead.
So instead of pulling from the master branch, moving forward we'll pull from the default main branch:
git pull origin main
If you are running into this error in any part of your software infrastructure, or suspect this change of github default branch name is causing an issue in your application, please get in touch and we'll help you solve the issue.
How to Fix Existing Repos
If you'd like to update any existing repos to use main as the new default branch name, just follow these steps:
Step 1 - Rename Local Branch
git branch -m master main
Step 2 - Rename Remote Branch
git checkout main
git push -u origin main
Step 3 - Delete 'master' Remote Branch
git push origin --delete master
If you receive an error you main need to go into the web UI for your git host (Github for instance) and find the setting for 'default branch' and switch it to main before deleting the old master branch.
Step 4 - Tell Others to Update Their Local Repos
They'll just need to run the following in their local repos:
# Switch to "master" branch
git checkout master
# Rename "master" branch to "main"
git branch -m master main
# Get latest commits and branches from remote
git fetch
# Remove existing connection with "master"
git branch --unset-upstream
# Create connection with new "main" branch
git branch -u origin/main