Here's what I did:
Checked out a remote git repository.
Added to the
[remote "origin]
section of.git/config
:
fetch = +refs/heads/release/BranchName:refs/remotes/origin/release/BranchName
- Checked out the corresponding branch:
git checkout origin/release/BranchName
After that git status
reported:
HEAD detached from origin/release/BranchName
Added and checked in some modifications.
Tries to
git push
. This resulted in the error message:
fatal: You are not currently on a branch. To push the history leading to the current (detached HEAD) state now, use
git push origin HEAD:<name-of-remote-branch>
- Then I followed the suggested command:
git push origin HEAD:origin/release/BranchName
and got the following:
error: unable to push to unqualified destination: origin/release/BranchName The destination refspec neither matches an existing ref on the remote nor begins with refs/, and we are unable to guess a prefix based on the source ref. error: failed to push some refs to 'RepositoryName`
Thus the questions: what did I do wrong? How to fix that and push the changes?
git checkout release/2018/MDP.2018.03
(drop theorigin/
part). With sufficiently recent versions of Git, this will create a local branch that tracks the remote branch of the same name. – Alienor