[英]Git: Stop Auto-merge when merging copied directory
I have a master branch, and a "newfeature" branch. 我有一个master分支和一个“ newfeature”分支。
In my newfeature branch, I copied directory A, calling the new folder Directory B. 在我的newfeature分支中,我复制了目录A,并将新文件夹称为目录B。
I then deleted directory A in "newfeature", just to make sure I wouldn't accidentally change anything there, as my new feature was to be in Directory B. 然后,我删除了“ newfeature”中的目录A,以确保我不会意外更改该目录中的任何内容,因为我的新功能位于目录B中。
I did some work in "newfeature", and committed it. 我在“ newfeature”中做了一些工作,并将其付诸实践。
Then, from master, I tried to merge in "newfeature" (git merge newfeature). 然后,从大师那里,我尝试在“ newfeature”中进行合并(git merge newfeature)。
However, git merges my changed files in Directory B (from "newfeature") with my files in Directory A (in "master"), and I'm just left with a Directory B. The message is like this: 但是,git将我在目录B中的更改文件(来自“ newfeature”)与我在目录A中的文件(位于“主”中)合并在一起,而我只剩下目录B。
Auto-merging B/somefile.php 自动合并B / somefile.php
How can I retain both Directory A, and Directory B, when merging? 合并时如何保留目录A和目录B?
Are you interested in preserving history for the directory you copied ? 您是否有兴趣保存复制目录的历史记录? If not, see below: When you copied directory A as directory B in new branch, you shouldn't run "git cp".
如果没有,请参见下文:在新分支中将目录A复制为目录B时,不应运行“ git cp”。 Just do a "cp".
只需执行一个“ cp”即可。 check the following sequence of commands I ran to achieve this.
检查以下我为实现此目的而运行的命令序列。
ls -al
cp -rf data-trial test
mkdir test; sudo cp -rf data-trial/* test/
cd test
cp -rf data-trial/.git .
cp -rf data-trial/.git .
git branch
git checkout -b test2
cp -rf tmp tmp2
git add tmp2
git commit
git log
git branch
git checkout feature/aws
cd tmp
ls -al
touch foo
vim foo
git status
git add foo
git commit
git log
git branch
git checkout test2
sudo git checkout test2
git merge feature/aws
sudo git merge feature/aws
ls -al
pwd
cd ..
ls -al
ls -al tmp
ls -al tmp2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.