结帐后Git(Sourcetree)问题

时间:2018-01-05 19:08:07

标签: git github atlassian-sourcetree

我是Git的初学者。我学会了如何在终端中使用,但现在我使用SourceTree。一切都很好,但第一次结账的时间已经来临。结帐后我继续我的任务,现在我有这两个分支,我不知道如何将以后的更改推送到远程。在遥控器上我只看到我检查过的那个。我应该将master设置为HEAD吗?我可以输入终端,我不关心SourceTree。

snippet from SourceTree

感谢您的回答!

3 个答案:

答案 0 :(得分:1)

此方案有各种解决方案

假设 你有2个分支,分支A和B. 首先你提交了分支A,现在你对分支B进行了一些更改

Origin是您的远程名称 分支机构驾驶室是您的主人

  1. 将更改推送到分支B中的远程 git push origin branch b

  2. 将您的更改合并到分支A然后再推送它 git checkout branch A git merge branch B git push origin branchA(分支A也可以是主人)

答案 1 :(得分:0)

如果您想将HEAD与主/原始分支混合使用:

进入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 :(得分:0)

感谢您的回答。我遇到了一些并发症(冲突),但最后使用Sourcetree我丢弃了相互冲突的更改,并且所有更改都出现在远程新分支上。

我学到的是,如果是这样的话,创建新的分支是必要的。

下面是终端转储,如果我做错了请求纠正我。

$ 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.