我刚刚清理了磁盘,现在我愿意回到从Gitlab下载回去的项目上工作。下载并进行少量更改后,我想通过创建新分支将其推回Gitlab。到目前为止,我所做的是:
git init
git remote add upstream https://gitlab.com/xxx/xxxxxxxxxx.git
git fetch upstream
键入最后一个命令后,它给了我3个分支的输出:
但是现在我要做的是:
我该如何进行呢?
答案 0 :(得分:1)
创建一个新分支并切换到该分支:
git checkout -b [branch name]
将更改提交到新分支(一旦完成):
git commit -a -m "Commit Message"
将分支推送到Gitlab:
git push --set-upstream [remote name] [branch name]
答案 1 :(得分:1)
一种典型的处理方式是
# create the new branch from some reference branch (master, x or y, your call)
git checkout -b <branchName> <referenceBranch>
# now make your changes in the code until you're fine with it
# add and commit those changes
git add path/to/file1 path/to/file2 path/to/file3
git commit -m "Useful message"
# push to gitlab with the -u option to set upstream
git push -u upstream <branchName>
在doc中查看有关设置上游的部分。