简体   繁体   English

如何将新代码推送到现有仓库? (作为一个新的分支)

[英]How do I push new code to an existing repo? (as a new branch)

  • I have an existing repo in gitlab with multiple branches我在 gitlab 中有一个现有的仓库,有多个分支
  • I did some work outside of that repo which I didn't mean to be part of it我在那个 repo 之外做了一些我不想参与其中的工作
  • I changed my mind and I want to push the new code, which is not a git repository, as a new branch of the existing repo我改变主意了,我想将不是 git 存储库的新代码作为现有 repo 的新分支推送

How do I do that?我怎么做?

The question's a bit vague but something like this should work (using Bash):这个问题有点含糊,但这样的事情应该可以工作(使用 Bash):

  1. Create a new branch in your existing repo在现有仓库中创建一个新分支

    git checkout -b $new_branch
  2. Copy/move the new code into the repo将新代码复制/移动到存储库中

    cp $new_code.
  3. Commit and push提交并推送

    git commit -am "Create $new_branch from external work in $new_code" git push -u origin $new_branch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM