我正在开发一个Git分支,它有一些破坏的测试,我想从另一个已经修复的分支中提取(合并更改,而不仅仅是覆盖)这些测试.
我知道我能做到
git pull origin that_other_branch
Run Code Online (Sandbox Code Playgroud)
但这将尝试合并许多其他文件,因为我尚未准备好.
是否可以从另一个分支中提取和合并指定的文件(而不是所有内容)?
这不仅仅是对一个文件的Git pull请求的重复,因为该问题的所有答案都是如何将本地更改的文件还原到存储库版本,而不更改任何分支.
所以我在编辑它之前忘了拉我的代码然后当我提交新代码并尝试推送时,我得到错误推送是不可能的,那时我做了一个"git pull",这使得一些文件突出显示冲突.我删除了冲突,但我不知道该怎么做...
我git commit再次尝试,但它说"提交是不可能的,因为你有未合并的文件"
我刚刚在git中将一个分支合并到了我的主人中,我得到了Automatic merge failed; fix conflicts and then commit the result.现在我跑了git mergetool,vimdiff打开了下面的图像.我不知道如何使用vimdiff.这里的每个小组意味着什么,我应该如何解决合并冲突?

我们有一个拥有超过400个提交的Git存储库,其中前几个是很多试错.我们希望通过将许多提交压缩到单个提交来清理这些提交.当然,git-rebase似乎还有很长的路要走.我的问题是它最终会出现合并冲突,而这些冲突并不容易解决.我不明白为什么会有任何冲突,因为我只是压缩提交(不删除或重新排列).很可能,这表明我并不完全理解git-rebase是如何做它的南瓜的.
这是我正在使用的脚本的修改版本:
repo_squash.sh(这是实际运行的脚本):
rm -rf repo_squash
git clone repo repo_squash
cd repo_squash/
GIT_EDITOR=../repo_squash_helper.sh git rebase --strategy theirs -i bd6a09a484b8230d0810e6689cf08a24f26f287a
Run Code Online (Sandbox Code Playgroud)
repo_squash_helper.sh(此脚本仅由repo_squash.sh使用):
if grep -q "pick " $1
then
# cp $1 ../repo_squash_history.txt
# emacs -nw $1
sed -f ../repo_squash_list.txt < $1 > $1.tmp
mv $1.tmp $1
else
if grep -q "initial import" $1
then
cp ../repo_squash_new_message1.txt $1
elif grep -q "fixing bad import" $1
then
cp ../repo_squash_new_message2.txt $1
else
emacs -nw $1
fi
fi
Run Code Online (Sandbox Code Playgroud)
repo_squash_list.txt :(此文件仅由repo_squash_helper.sh使用)
# Initial import
s/pick \(251a190\)/squash …Run Code Online (Sandbox Code Playgroud) 我们使用git并拥有一个主分支和开发人员分支.我需要添加一个新功能,然后将提交重新设置为master,然后将master推送到CI服务器.
问题是,如果我在rebase期间遇到冲突,我不能在rebase完成后推送到我的远程开发人员分支(在Github上),直到我拉出我的远程分支.这会导致重复提交.没有冲突时,按预期工作.
问题:在rebase和冲突解决之后,如何在不创建重复提交的情况下同步我的本地和远程开发人员分支
建立:
// master branch is the main branch
git checkout master
git checkout -b myNewFeature
// I will work on this at work and at home
git push origin myNewFeature
// work work work on myNewFeature
// master branch has been updated and will conflict with myNewFeature
git pull --rebase origin master
// we have conflicts
// solve conflict
git rebase --continue
//repeat until rebase is complete
git push origin myNewFeature
//ERROR
error: failed to push some …Run Code Online (Sandbox Code Playgroud) 我是组织中唯一一个使用以下消息进行提交的人:
将远程跟踪分支'origin/develop'合并到develop中
不知道我在做什么导致他们,但我想停下来.
我发出什么命令来创建这个提交,我应该用什么命令来生成它?
我正在为我的git项目使用(Windows)SourceTree.我可以在命令提示符或Linux终端中执行此操作.
但是,我想知道是否有一种交互式和视觉上解决冲突的好方法.例如,如果pull检测到冲突,则弹出基于GUI的冲突工具(例如,P4Merge).可能吗?
我总是在做手动冲突解决,这很痛苦.
例如,这是pull来自SourceTree 的git 消息.
git -c diff.mnemonicprefix=false -c core.quotepath=false pull --no-commit origin master
From W:\repo\
* branch master -> FETCH_HEAD
Updating 33c07bf..41e0249
error: Your local changes to the following files would be overwritten by merge:
foo.cpp
goo.cpp
goo.hpp
Please, commit your changes or stash them before you can merge.
Aborting
Completed with errors, see above.
Run Code Online (Sandbox Code Playgroud) git git-merge merge-conflict-resolution atlassian-sourcetree
我已经在git中设置了一些远程跟踪分支,但是一旦我用'git fetch'更新它们,我似乎永远无法将它们合并到本地分支中.
例如,假设我有一个名为'an-other-branch'的远程分支.我在本地设置为跟踪分支使用
git branch --track an-other-branch origin/an-other-branch
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好.但是如果该分支得到更新(通常是我移动机器并从该机器提交),并且我想在原始机器上更新它,我遇到了fetch/merge的问题:
git fetch origin an-other-branch
git merge origin/an-other-branch
Run Code Online (Sandbox Code Playgroud)
每当我这样做时,我都会得到一条"已经是最新的"消息,并且没有任何合并.
但是,一个
git pull origin an-other-branch
Run Code Online (Sandbox Code Playgroud)
总是像你期望的那样更新它.
另外,运行git diff
git diff origin/an-other-branch
Run Code Online (Sandbox Code Playgroud)
表明存在差异,所以我认为我的语法错了.
我究竟做错了什么?
编辑[2010-04-09]:我已经检查了几次,我肯定不在另一个分支上.我的'git fetch'后跟'git merge'(如上所示)是否应该与git pull完全相同?我将得到一些显示git状态等结果的工作流程.
今天我试图使用git mergetoolWindows命令提示符,并意识到它默认使用VIM,这很酷,但我更喜欢VSCode.
如何将Visual Studio代码功能作为我的GUI来处理Git的合并冲突(甚至作为差异化工具)?
git-merge ×10
git ×9
git-fetch ×2
git-pull ×2
git-rebase ×2
mergetool ×2
cmd ×1
git-branch ×1
git-checkout ×1
git-remote ×1
git-tag ×1
merge ×1
rebase ×1
vim ×1