简体   繁体   中英

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

  • I have an existing repo in gitlab with multiple branches
  • I did some work outside of that repo which I didn't mean to be part of it
  • 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

How do I do that?

The question's a bit vague but something like this should work (using 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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