2

I'm trying to rebase my feature branch to the master branch. But, when I try to pull or fetch using git, it's not even pulling the master branch from the remote to the local.

Here are the steps which I tried

$ git merge origin/master
merge: origin/master - not something we can merge

$ git merge master
merge: master - not something we can merge      

$ git branch -r
origin/feature

 git branch -a
 * feature
  remotes/origin/feature


$ git fetch --all
Fetching origin

$ git pull --all
Fetching origin
Already up to date.

I cloned in the following way

git clone https://github.optum.com/<Repo details> --branch feature --single-branch
Syed
  • 2,471
  • 10
  • 49
  • 89
  • 1
    It looks like you don't have a `master` branch. What is the output of `git branch` with no options, or `git branch -a`? Along similar lines: what is the output of `git config --get-all remote.origin.fetch`? How did you make the clone? – torek Nov 22 '19 at 09:10
  • @torek, updated in the question. Please check – Syed Nov 22 '19 at 09:13
  • 1
    Clone without using `--single-branch` – jessehouwing Nov 22 '19 at 09:17

2 Answers2

3

This is caused by the fact you cloned with --single-branch, this changer the repos configuration to scope all commands to that specific branch for the remote. You can undo the command or add another branch as explained here.

git remote set-branches --add origin [remote-branch]
git fetch origin [remote-branch]:[local-branch]
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
2

From git help clone for the --single-branch option:

Clone only the history leading to the tip of a single branch, either specified by the --branch option or primary branch remote’s HEAD points at. Further fetches into the resulting repository will only the remote-tracking branch for the branch this option was used for the initial cloning. If the at the remote did not point at any branch when --single-branch clone was made, no remote-tracking is created.

This would suggest your clone has only cloned the history of the feature branch, hence why your local repository has no idea that a master (or any other branches) exist on the remote.

As I was typing this, @jessehouwing answered with instructions how to fix this

Pesho_T
  • 814
  • 1
  • 6
  • 18