Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT how to merge master into branch cloned with -single-branch

I have a git repository, where master is the current version of the application and each customer has their own branch with their own customizations.

I have cloned each customers branch separately into a directory using --single-branch

My goal is to merge master into my branch. I have cloned the repo using following command:

git clone {{REPO_URL}} --single-branch my-branch --branch my-branch

Then I tried:

git fetch origin -- master

git merge master

Then I am getting this

merge: master - not something we can merge

I know I could get around this by cloning entire repository, but is there anyway to work around this?

like image 970
Firze Avatar asked Nov 21 '25 05:11

Firze


1 Answers

You just need to add the url as another remote in your local repo.

Detail commands as below:

# In local my-branch
git remote add upstream <repo URL> -f
git merge upstream/master

Now your local my-branch contains the changes from master branch.


Update: to add remote only for master branch, you can use the command:

git remote add upstream <repo URL> -t master -f

If you already add the remote upstream with all branches, you can change it by:

git remote rm upstream
git remote add upstream <repo URL> -t master -f
like image 105
Marina Liu Avatar answered Nov 23 '25 01:11

Marina Liu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!