Git (Sourcetree) 签出后问题
Git (Sourcetree) issue after checkout
我是 Git 的新手。我学会了如何在终端中使用,但现在我使用 SourceTree。一切都很好,但第一次结账的时间到了。结帐后,我继续执行任务,现在我有这两个分支,但我不知道如何将以后的更改推送到远程。在远程我只看到我签出的那个。我应该将 master
设置为 HEAD
吗?我可以输入终端,我不关心 SourceTree。
感谢您的解答!
如果您想将 HEAD 与 master/origin 分支混合使用:
进入你的 HEAD,打开控制台:
// (You are currently working on a detached HEAD and not in a proper branch)
git checkout -b harvestFile // Checkout your detached HEAD to a new branch Properly
git checkout master // Go back to your master branch
git merge harvestFile // Merge HarvestFile into master
git push origin // Push master to your remote.
如果你想用你的 HEAD 替换 master :
进入你的 HEAD,打开控制台::
// (You are currently working on a detached HEAD and not in a proper branch)
git checkout -b harvestFile // Checkout your detached HEAD to a new branch Properly
git checkout master // Go back to your master branch
git merge -s ours harvestFile // Merge HarvestFile into master only keep harvestFile branch commits
git push origin // Push master to your remote.
如果您想使用 HEAD 中的代码创建一个新的远程分支:
进入你的 HEAD,打开控制台::
// (You are currently working on a detached HEAD and not in a proper branch)
git checkout -b <branchname> // Checkout your detached HEAD to a new branch Properly
git push -u origin <branchname> // Push and create <branchname> on your remote.
这种情况有多种解决方案
假设
您有 2 个分支,分支 A 和 B
首先,您在分支 A 上提交,现在您在分支 B
上进行了一些更改
Origin 是您的远程名称
Branch A cab 做你的主人
将您的更改推送到分支 B 中的远程
git push origin branch b
将您的更改合并到分支 A,然后推送它
git checkout branch A
git merge branch B
git push origin branchA
(分支A也可以是master)
感谢您的回答。我 运行 遇到了一些并发症(冲突)但最终使用 Sourcetree 我放弃了冲突的更改并且所有出现在新 b运行ch 上的远程。
我了解到,在这种情况下,有必要创建新的 b运行ch 以继续前进。
以下为终端转储,如有错误请指正。
$ git checkout -b mailing
Switched to a new branch 'mailing'
.../APFA 1.0/APMailTool (mailing)
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
.../APFA 1.0/APMailTool (master)
$ git merge mailing
Auto-merging AP_MailCreation.bas
CONFLICT (content): Merge conflict in AP_MailCreation.bas
Automatic merge failed; fix conflicts and then commit the result.
.../APFA 1.0/APMailTool (master|MERGING)
$ git merge -s ours mailing
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
我是 Git 的新手。我学会了如何在终端中使用,但现在我使用 SourceTree。一切都很好,但第一次结账的时间到了。结帐后,我继续执行任务,现在我有这两个分支,但我不知道如何将以后的更改推送到远程。在远程我只看到我签出的那个。我应该将 master
设置为 HEAD
吗?我可以输入终端,我不关心 SourceTree。
感谢您的解答!
如果您想将 HEAD 与 master/origin 分支混合使用:
进入你的 HEAD,打开控制台:
// (You are currently working on a detached HEAD and not in a proper branch)
git checkout -b harvestFile // Checkout your detached HEAD to a new branch Properly
git checkout master // Go back to your master branch
git merge harvestFile // Merge HarvestFile into master
git push origin // Push master to your remote.
如果你想用你的 HEAD 替换 master :
进入你的 HEAD,打开控制台::
// (You are currently working on a detached HEAD and not in a proper branch)
git checkout -b harvestFile // Checkout your detached HEAD to a new branch Properly
git checkout master // Go back to your master branch
git merge -s ours harvestFile // Merge HarvestFile into master only keep harvestFile branch commits
git push origin // Push master to your remote.
如果您想使用 HEAD 中的代码创建一个新的远程分支:
进入你的 HEAD,打开控制台::
// (You are currently working on a detached HEAD and not in a proper branch)
git checkout -b <branchname> // Checkout your detached HEAD to a new branch Properly
git push -u origin <branchname> // Push and create <branchname> on your remote.
这种情况有多种解决方案
假设 您有 2 个分支,分支 A 和 B 首先,您在分支 A 上提交,现在您在分支 B
上进行了一些更改Origin 是您的远程名称 Branch A cab 做你的主人
将您的更改推送到分支 B 中的远程
git push origin branch b
将您的更改合并到分支 A,然后推送它
git checkout branch A
git merge branch B
git push origin branchA
(分支A也可以是master)
感谢您的回答。我 运行 遇到了一些并发症(冲突)但最终使用 Sourcetree 我放弃了冲突的更改并且所有出现在新 b运行ch 上的远程。
我了解到,在这种情况下,有必要创建新的 b运行ch 以继续前进。
以下为终端转储,如有错误请指正。
$ git checkout -b mailing
Switched to a new branch 'mailing'
.../APFA 1.0/APMailTool (mailing)
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
.../APFA 1.0/APMailTool (master)
$ git merge mailing
Auto-merging AP_MailCreation.bas
CONFLICT (content): Merge conflict in AP_MailCreation.bas
Automatic merge failed; fix conflicts and then commit the result.
.../APFA 1.0/APMailTool (master|MERGING)
$ git merge -s ours mailing
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.