I have a project with a few friends in GitLab, and there is of course the master branch, and there are some others too. When I cloned the repository, I created also an upstream with the command
git remote add upstream ...
git fetch upstream
git checkout upstream/test1
git branch -a
* (HEAD detached at upstream/test1)
remotes/origin/HEAD -> origin/master
git add .
git commit -m "Sample message"
[detached HEAD 4f20e95] Sample message
5 files changed, 12 insertions(+), 1 deletions(-)
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>
upstream/test1 is a remote tracking branch, which can't be updated manually. Such branches track branches on remote servers, and are only updated during
Instead, check out a new local branch first:
git checkout -b test1 upstream/test1
And commit there as usual. Since you have already committed, instead do:
git checkout -b test1 4f20e95
When you are ready, push to
git push upstream test1
When you do a plain
git push, Git uses default values for the remote and branch to push based on certain config options. However, if you aren't on a branch (thus getting the
detached HEAD message), then Git doesn't know what branch to push, thus giving you the error you received.