Push local master commits to remote branch

后端 未结 3 1376
花落未央
花落未央 2020-12-14 04:28

I\'ve been working on a local clone of a remote git repository, committing my changes to my local master branch. Now, I want to push my commits to the remote repository. How

相关标签:
3条回答
  • 2020-12-14 05:13

    You should run git help push, which will tell you about the syntax for the refspec that you push to. In short, git push <remotename> <local_branch_name>:<remote_branch_name>

    0 讨论(0)
  • 2020-12-14 05:15

    What I did was creatE a new local branch for example name it test1

    > git checkout -b test1

    This command will create a branch and switch to it directly, and then push your new local branch to your remote repository either GitHub or GitLab by typing

    > git push origin test1

    don't forget to check the correct link by typing.

    > git remote --v

    0 讨论(0)
  • 2020-12-14 05:18

    I was not able to do this with a single command. First I commit all my changes to my local master. Then I create a new local branch called "mybranch" using

    git checkout -b mybranch
    

    and then I pushed that using

    git push -u origin mybranch
    

    in my case origin is the remote name. Your remote name might be different. You can use git remote -v to see what your remote name should be.

    After the push, if you want, you can get rid of your local branch using these two commands

    git checkout master
    git branch -d mybranch
    

    hope that helps.

    0 讨论(0)
提交回复
热议问题