我有点像git n00b,我在分支方面遇到了一些困难。我不认为这个问题有问题,但可能只是因为我没有找到合适的关键字。
情况: 我有一个远程git存储库,我已经检查了机器1上的主分支。 我在机器2上做了同样的事情,除了我创建了一个新的分支(沙箱)并检查了它。
我拉动,进行更改,提交并推送机器2上的东西 - 没问题。
然后我在Machine one上做了一些更改,提交并尝试推送,除了我收到此错误:
To xxx@xxx.xxx.com:/project.git
! [rejected] sandbox -> sandbox (non-fast-forward)
error: failed to push some refs to 'xxx@xxx.xxx.com:/project.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
如果我做了一个git pull,我得到:
Already up-to-date.
所以目前我必须
git checkout sandbox
git pull
git checkout master
git push
然后一切都很好。在我看来,鉴于这些是不同的分支,我不应该在沙箱分支上拉动以推动对主人的更改。如果我试图合并它们,我可以理解它,但这可能永远不会发生。
我怀疑我的配置文件有点不对,所以这里是:
(Machine 1 - master) .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[gui]
wmstate = normal
geometry = 1920x970+0+0 368 203
[remote "origin"]
url = xxx@xxx.xxx.com:/project.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
并且
(Machine 2 - paid) .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git+ssh://xxx@xxx.xxx.com/project.git
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "sandbox"]
remote = origin
merge = refs/heads/sandbox
应该注意的是,同样的问题发生在逆转中 - 在推送主机之后,我无法在没有检查主机的情况下推送沙箱,执行拉动然后切换回沙箱。
必须有一种更简单的方法 - 任何帮助都会受到赞赏。