How to push changes as a branch to remote server not in Main line

I have pulled a project from git repository(remote server). I did some modification.

Now I need to push as branch in a server not in main line.
For example, In server, V1->V2->V3.
My working area is on V2. And I want to push as V2.1. Not as V4.

  • Working in Git Branch, and then deciding a need a new branch, some files already committed
  • Create new repo by 'git remote add origin' and 'push'
  • Using git for the first time
  • What is the old command of git clone -c in git version 1.7.1
  • error using git push
  • Git push not working, no error
  • Usual command i used for Pushing is git push origin HEAD:refs/for/master/issue5221.
    Is there some thing to replace master in that command to push as a branch?

    I tried some thing like this git push origin HEAD:refs/for/my_branch/issue5221. But it is not working. Since “my_branch” is not in remote server.

  • git submodules with modified and untracked content - why and how to remove it?
  • Automate AssemblyFileVersion Incrementation using GIT
  • Error when syncing with Github for Mac app
  • Recovering broken git repository
  • Git: How to make an experimental branch head/master?
  • Push a git repo to a remote server via ssh
  • 2 Solutions collect form web for “How to push changes as a branch to remote server not in Main line”

    You should be able to push HEAD to a new branch (created on receiving the commit) with:

    git push origin HEAD:my_branch/issue5221
    

    (more generally, you can push a local branch to a remote repo on a different branch)

    It seems you are using Gerrit. So you need ask the administrator to create the branch refs/heads/my_branch/issue5221, after which you can push to refs/for/my_branch/issue5221. If this is not an official branch, you can push it to a sandbox branch via git push origin HEAD:refs/sandbox/<your-username>/<any-name-you-want>. refs/sandbox/<your-username>/* cannot be fetched via git clone, but can be done via git fetch origin refs/sandbox/<your-username>/* && git checkout FETCH_HEAD. And other users are not allowed to update this ref.

    Git Baby is a git and github fan, let's start git clone.