没有远程存储库,只有一个具有两个分支的本地存储库.
$ git branch -a
master
* devel
Run Code Online (Sandbox Code Playgroud)
以下命令在此上下文中是相同的/同义词吗?
$ git pull . master
Run Code Online (Sandbox Code Playgroud)
和
$ git merge master
Run Code Online (Sandbox Code Playgroud)
更新:
$ git help pull 提供以下信息
SYNOPSIS
git pull <options> <repository> <refspec>...
DESCRIPTION
...
Note that you can use . (current directory) as the <repository> to pull
from the local repository — this is useful when merging local branches
into the current branch.
Run Code Online (Sandbox Code Playgroud)
我实际上不明白为什么这个有用,如本手册中所述.
我犯了一个错误:我应该使用git pull --rebase,但我发布了一个简单的git pull,合并的所有内容,现在在我的分支的HEAD中有一个合并提交.
我想摆脱那个合并提交,我想我只是发出一个git rebase -i HEAD~3,将我的最后一个本地提交移到顶部并将合并提交压缩到它中.唉,合并提交不适用于压缩.如果我这样做,我进入中间状态,我需要再次进行合并,这是很多工作.
有没有办法解决这个问题而不必再次执行合并?似乎应该可以以某种方式使用合并提交?
我有以下目录结构:
/.git
/.git/info/attributes
/MyProject
/MyProject/pom.xml
/MyProject/MyCode.java
Run Code Online (Sandbox Code Playgroud)
我有分支主和bugfix.在两个分支上都修改了pom.xml和MyCode.java.我想将仅来自bugfix的更改合并到MyCode.java的master,并保留pom.xml文件的主版本.
所以我添加了"/.git/info/attributes"因为我不想在项目中提交.gitattributes
$cat .git/info/attributes
pom.xml merge=ours
$git status
# On branch master
nothing to commit (working directory clean)
$git check-attr -a pom.xml
pom.xml: merge: ours
Run Code Online (Sandbox Code Playgroud)
最后到了问题:
当我做:
$git merge bugfix
Auto-merging MyProject/pom.xml
CONFLICT (content): Merge conflict in MyProject/pom.xml
Automatic merge failed; fix conflicts and then commit the result.
Run Code Online (Sandbox Code Playgroud)
Git忽略了属性设置.我在这里失踪了什么?
我不想在这篇文章中定义"keepMine.sh"
这篇文章是我需要的,但是如果我有一个简单的模式,我宁愿不逐个文件
谢谢!
从git书:
你会注意到那个合并中的短语"快进".因为您合并的分支所指向的提交直接位于您所在的提交的上游,所以Git将指针向前移动.换句话说,当你尝试将一个提交与可以通过遵循第一个提交的历史记录到达的提交合并时,Git通过向前移动指针来简化事情,因为没有不同的工作要合并在一起 - 这称为"快进".
但是,此"快进"的副作用是,如果您有一个具有多个提交的功能分支,则在合并回主服务器时将丢失该功能的历史上下文.换句话说,提交不会被组合在一起作为此功能的一部分.
with fast forward: x---x---x---x---x---x---x
without fast forward: x---x---x x---x---x---x
\x--x--x/
Run Code Online (Sandbox Code Playgroud)
手动方式是 git merge --no-ff
有谁知道如何将其设置为默认值?
我有一个git存储库master和alt分支.alt分支包含修改后的master代码版本,我正在尝试将更改合并master到alt这样:
git merge --squash master
Run Code Online (Sandbox Code Playgroud)
合并导致冲突:
Auto-merging myproject/foo/bar
CONFLICT (content): Merge conflict in myproject/foo/bar
Squash commit -- not updating HEAD
Automatic merge failed; fix conflicts and then commit the result.
Run Code Online (Sandbox Code Playgroud)
在我解决冲突并提交更改之后,一切似乎都很好,但是当我git merge --squash master再次运行时(不对任何分支进行任何更改)我将得到相同的冲突错误.
这是为什么?我错过了什么?
我见过人们建议所有开发人员在他们的机器上设置符号链接C:\project\.git\rr-cache到共享文件夹\\server\rr-cache.
但是,如果可以的话,通过将文件夹包含在git存储库中来共享文件夹似乎更方便.我见过人们提到这个解决方案,但实际上并不是这样做的.
有任何想法吗?
git version-control git-merge merge-conflict-resolution git-rerere
我目前有两个分支机构,我正在研究.由于软件更新,我必须完全更改文件夹结构.因此我在两个分支中移动文件.现在我达到了一个点,我想将我的工作分支合并到我的主分支中.
问题是存在合并冲突,告诉我文件仅由一个分支(added by them或added by us)添加.问题是两个分支都添加了该文件.
例如,我有一个纹理textures/texture1.png.主分支刚刚将其移动到正确的位置(之前misc/textures/texture1.png).工作分支将其移动到完全相同的位置并在之后进行编辑.此文件的合并冲突说:
added by us: textures/texture1.png
Run Code Online (Sandbox Code Playgroud)
关键是这不是我想要的文件!我想要来自其他分支的文件!
当我做
git checkout --theirs textures/texture1.png
Run Code Online (Sandbox Code Playgroud)
我明白了
error: path 'textures/texture1.png' does not have their veresion
Run Code Online (Sandbox Code Playgroud)
但是这个文件确实存在!我最近加了!这就是我想要的文件
我该如何解决这些冲突?
(如果需要更多信息!)
因此,由于某些原因,我与新的合并修补程序发生了很多冲突.实际上[手动]更改的文件没有冲突.所有冲突都存在于修复期间未触及的文件中,显然是空白问题.我稍后会尝试解决该问题,但现在我需要合并修补程序和部署.
如何解决所有冲突以使用HEAD版本?我不想一个接一个地去.是的,我知道这是一个不好的做法,但冲突都是空白,我知道HEAD是正确的 - 通过所有测试并在生产中运行良好.
有任何想法吗?
我正在使用OSX.
在合并冲突中,我正在尝试解决所有合并冲突,以支持特定分支.
我正在尝试git checkout --ours,但我收到以下错误:
fatal: '--ours/--theirs' cannot be used with switching branches
Run Code Online (Sandbox Code Playgroud)
我怎样才能实现我想做的事情?
我有一个git仓库mainline(相当于master)和一些本地功能分支.例如:
$ git branch
* mainline
feature1
feature2
feature3
Run Code Online (Sandbox Code Playgroud)
当我执行以下操作时,我能够将功能分支中的所有编辑内容合并为一个提交到mainline:
$ git checkout mainline
$ git pull
$ git checkout feature1
$ git rebase mainline
$ git checkout mainline
$ git merge --squash feature1
$ git commit
$ git push
Run Code Online (Sandbox Code Playgroud)
我的问题是,在这一点上,当我尝试删除feature1分支时,它告诉我它没有完全合并:
$ git branch -d feature1
error: The branch 'feature1' is not fully merged.
If you are sure you want to delete it, run 'git branch -D feature1'.
Run Code Online (Sandbox Code Playgroud)
是什么导致这个错误?我以为git merge --squash …
git ×10
git-merge ×10
git-branch ×1
git-pull ×1
git-rebase ×1
git-rerere ×1
merge ×1
opendiff ×1