为什么删除有冲突的文件会中断项目? [英] Why does deleting a conflicted file break a project?

查看:105
本文介绍了为什么删除有冲突的文件会中断项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在已经发生过3次这种情况,我想尝试修复它,而不是删除项目并重新克隆它.例如,请参见 openssl-dev,链接错误[heartbeat_test]错误2 .

I've had this happen to me three times now, and I'd like to try to fix it rather than deleting the project and re-cloning it. See, for example, openssl-dev, link error [heartbeat_test] Error 2.

我通过git clone git://git.openssl.org/openssl.git克隆了 openssl-dev .

今天,我做了git pull,但由于文件冲突而失败.为了解决冲突,我执行了以下操作:

Today, I did a git pull and it failed because of conflicting files. To resolve the conflicts, I performed:

rm apps/Makefile
rm crypto/engine/Makefile
rm crypto/evp/Makefile
rm ssl/Makefile
rm test/Makefile

删除冲突后,git pull成功,我尝试构建.

After deleting the conflicts, the git pull succeeded and I attempted build.

现在,这是我迷路的地方.构建失败,并带有重复的符号(如下所示).如果执行彻底清理并制作(dclean是OpenSSL的dist-clean版本),它将失败:

Now, here's where I get lost. The build fails with duplicate symbols (shown below). It fails if I perform a complete clean and make (dclean is OpenSSL's version of dist-clean):

make clean && make dclean && export KERNEL_BITS=64 && ./config && make

如果我扔一个makedepend,它会失败:

And it fails if I toss in a make depend:

make clean && make dclean && export KERNEL_BITS=64 && ./config && make depend && make

认为清理后可能会放一些目标文件,但没有:

I thought there might be some object files lying around after the clean, but there were none:

$ find . -iname *.o
$ 

如果我执行全新克隆,那么一切都会按预期进行.

If I perform a fresh clone, then everything works as expected.

git clonegit pull(干净地制作)之间的区别是什么?

What is the difference between the git clone and the git pull (with a clean and make) that would cause this problem?

或者git有什么问题,我该如何解决?

Or what is the problem with git, and how do I resolve it?

openssl-git$ make clean && make dclean && export KERNEL_BITS=64 && \
    ./config && make depend && make
...
cc -I.. -I../include  -I../fips -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H 
-arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT 
-DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM 
-DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM   -c -o heartbeat_test.o 
heartbeat_test.c

cc -I.. -I../include  -I../fips -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H 
-arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT 
-DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM 
-DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM   -c -o testutil.o testutil.c

( :; LIBDEPS="${LIBDEPS:--Wl,-search_paths_first ../libssl.a ../libcrypto.a  }"; 
LDCMD="${LDCMD:-cc}"; LDFLAGS="${LDFLAGS:--DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN 
-DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT 
-DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM 
-DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM}"; LIBPATH=`for x in $LIBDEPS; do 
echo $x; done | sed -e 's/^ *-L//;t' -e d | uniq`; LIBPATH=`echo $LIBPATH | sed -e 's/ /:/g'`; 
LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:=heartbeat_test} 
heartbeat_test.o testutil.o ${LIBDEPS} )

duplicate symbol _main in:
    heartbeat_test.o
    testutil.o

ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [link_app.] Error 1
make[1]: *** [heartbeat_test] Error 2
make: *** [build_tests] Error 1


由于这种情况过去已经发生过多次,所以我知道这不是一个一次性的问题.


Because this has happened multiple times in the past, I know this is not a one-off problem.

我添加了标记的问题,因为它是项目,但我很确定潜在的问题是git.

I added the openssl tag because it's the project, but I'm pretty sure the underlying problem is with git.

我保存了项目而不是删除了项目,因此我可以将其压缩并上传以进行检查(如果需要).

I saved the project rather than deleting it, so I can tar it and upload it for inspection (if needed).

最后:

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.8.5
BuildVersion:   12F45


下面的openssl-git是我的OpenSSL副本所在的位置.它有我的mod和调整. openssl-git-test是用于测试的新鲜克隆.我在差异化之前跑了find . -name '*.save' -exec rm -rf {} \;.


Below, openssl-git is where my copy of OpenSSL is located. It has my mods and tweaks. openssl-git-test is the fresh clone for testing. I ran find . -name '*.save' -exec rm -rf {} \; before diff'ing.

$ diff --brief -r openssl-git/ openssl-git-test/
Only in openssl-git/: .DS_Store
Only in openssl-git/.git: FETCH_HEAD
Only in openssl-git/.git: ORIG_HEAD
Files openssl-git/.git/index and openssl-git-test/.git/index differ
Files openssl-git/.git/logs/HEAD and openssl-git-test/.git/logs/HEAD differ
Files openssl-git/.git/logs/refs/heads/master and openssl-git-test/.git/logs/refs/heads/master differ
Files openssl-git/.git/logs/refs/remotes/origin/HEAD and openssl-git-test/.git/logs/refs/remotes/origin/HEAD differ
Only in openssl-git/.git/logs/refs/remotes/origin: OpenSSL_0_9_8-stable
Only in openssl-git/.git/logs/refs/remotes/origin: OpenSSL_1_0_0-stable
Only in openssl-git/.git/logs/refs/remotes/origin: OpenSSL_1_0_1-stable
Only in openssl-git/.git/logs/refs/remotes/origin: OpenSSL_1_0_2-stable
Only in openssl-git/.git/logs/refs/remotes/origin: master
Only in openssl-git/.git/objects: 00
Only in openssl-git/.git/objects: 02
Only in openssl-git/.git/objects: 05
Only in openssl-git/.git/objects: 07
Only in openssl-git/.git/objects: 08
Only in openssl-git/.git/objects: 09
Only in openssl-git/.git/objects: 0a
Only in openssl-git/.git/objects: 0e
Only in openssl-git/.git/objects: 0f
Only in openssl-git/.git/objects: 13
Only in openssl-git/.git/objects: 18
Only in openssl-git/.git/objects: 1b
Only in openssl-git/.git/objects: 1c
Only in openssl-git/.git/objects: 1d
Only in openssl-git/.git/objects: 23
Only in openssl-git/.git/objects: 24
Only in openssl-git/.git/objects: 25
Only in openssl-git/.git/objects: 28
Only in openssl-git/.git/objects: 2a
Only in openssl-git/.git/objects: 2c
Only in openssl-git/.git/objects: 36
Only in openssl-git/.git/objects: 37
Only in openssl-git/.git/objects: 38
Only in openssl-git/.git/objects: 3e
Only in openssl-git/.git/objects: 3f
Only in openssl-git/.git/objects: 42
Only in openssl-git/.git/objects: 44
Only in openssl-git/.git/objects: 4a
Only in openssl-git/.git/objects: 54
Only in openssl-git/.git/objects: 58
Only in openssl-git/.git/objects: 5c
Only in openssl-git/.git/objects: 5d
Only in openssl-git/.git/objects: 60
Only in openssl-git/.git/objects: 61
Only in openssl-git/.git/objects: 63
Only in openssl-git/.git/objects: 66
Only in openssl-git/.git/objects: 67
Only in openssl-git/.git/objects: 68
Only in openssl-git/.git/objects: 6e
Only in openssl-git/.git/objects: 6f
Only in openssl-git/.git/objects: 71
Only in openssl-git/.git/objects: 72
Only in openssl-git/.git/objects: 78
Only in openssl-git/.git/objects: 79
Only in openssl-git/.git/objects: 7b
Only in openssl-git/.git/objects: 80
Only in openssl-git/.git/objects: 82
Only in openssl-git/.git/objects: 84
Only in openssl-git/.git/objects: 87
Only in openssl-git/.git/objects: 88
Only in openssl-git/.git/objects: 8d
Only in openssl-git/.git/objects: 8e
Only in openssl-git/.git/objects: 99
Only in openssl-git/.git/objects: 9f
Only in openssl-git/.git/objects: a0
Only in openssl-git/.git/objects: a3
Only in openssl-git/.git/objects: a4
Only in openssl-git/.git/objects: a8
Only in openssl-git/.git/objects: a9
Only in openssl-git/.git/objects: ae
Only in openssl-git/.git/objects: af
Only in openssl-git/.git/objects: b2
Only in openssl-git/.git/objects: b5
Only in openssl-git/.git/objects: ba
Only in openssl-git/.git/objects: bc
Only in openssl-git/.git/objects: bd
Only in openssl-git/.git/objects: be
Only in openssl-git/.git/objects: c4
Only in openssl-git/.git/objects: c5
Only in openssl-git/.git/objects: c6
Only in openssl-git/.git/objects: d3
Only in openssl-git/.git/objects: d5
Only in openssl-git/.git/objects: d6
Only in openssl-git/.git/objects: d7
Only in openssl-git/.git/objects: da
Only in openssl-git/.git/objects: db
Only in openssl-git/.git/objects: de
Only in openssl-git/.git/objects: e0
Only in openssl-git/.git/objects: e3
Only in openssl-git/.git/objects: e7
Only in openssl-git/.git/objects: e8
Only in openssl-git/.git/objects: e9
Only in openssl-git/.git/objects: ed
Only in openssl-git/.git/objects: ef
Only in openssl-git/.git/objects: f2
Only in openssl-git/.git/objects: fa
Only in openssl-git/.git/objects: fb
Only in openssl-git/.git/objects: fc
Only in openssl-git/.git/objects/pack: pack-663dfba6981c559658fb9253e5456938cd330c97.idx
Only in openssl-git/.git/objects/pack: pack-663dfba6981c559658fb9253e5456938cd330c97.pack
Only in openssl-git-test/.git/objects/pack: pack-97e4b04a1ce519e33653e4f4ef941fed44f53332.idx
Only in openssl-git-test/.git/objects/pack: pack-97e4b04a1ce519e33653e4f4ef941fed44f53332.pack
Only in openssl-git/.git/objects/pack: pack-a5611b625ffa369803ca57e5d198864c4c3933a4.idx
Only in openssl-git/.git/objects/pack: pack-a5611b625ffa369803ca57e5d198864c4c3933a4.pack
Only in openssl-git/.git/objects/pack: pack-feccfacff9cc5bff523280a162d04c2c3813bba8.idx
Only in openssl-git/.git/objects/pack: pack-feccfacff9cc5bff523280a162d04c2c3813bba8.pack
Files openssl-git/.git/packed-refs and openssl-git-test/.git/packed-refs differ
Files openssl-git/.git/refs/heads/master and openssl-git-test/.git/refs/heads/master differ
Only in openssl-git/.git/refs/remotes/origin: OpenSSL_0_9_8-stable
Only in openssl-git/.git/refs/remotes/origin: OpenSSL_1_0_0-stable
Only in openssl-git/.git/refs/remotes/origin: OpenSSL_1_0_1-stable
Only in openssl-git/.git/refs/remotes/origin: OpenSSL_1_0_2-stable
Only in openssl-git/.git/refs/remotes/origin: master
Only in openssl-git/.git/refs/tags: OpenSSL_0_9_8zb
Only in openssl-git/.git/refs/tags: OpenSSL_1_0_0n
Only in openssl-git/.git/refs/tags: OpenSSL_1_0_1i
Files openssl-git/doc/apps/ciphers.pod and openssl-git-test/doc/apps/ciphers.pod differ
Files openssl-git/doc/apps/pkcs8.pod and openssl-git-test/doc/apps/pkcs8.pod differ
Only in openssl-git/engines: e_padlock-x86.s
Only in openssl-git/: s3_enc.c.diff
Files openssl-git/ssl/s3_clnt.c and openssl-git-test/ssl/s3_clnt.c differ
Files openssl-git/ssl/s3_enc.c and openssl-git-test/ssl/s3_enc.c differ
Files openssl-git/ssl/s3_lib.c and openssl-git-test/ssl/s3_lib.c differ
Files openssl-git/ssl/tls1.h and openssl-git-test/ssl/tls1.h differ

推荐答案

我猜测是基于一些地方发现的一些其他项目,但听起来像是:

I'm guessing a bit based on some other items found in a few places, but it sounds like:

  • 您正在使用git克隆某些内容,只是为了获得它的某个版本,而您不打算对其进行编辑.
  • 您要克隆的事物在其正常操作过程中会在其自身的源树中对其进行编辑.这在git或大多数版本控制系统中表现不佳. (使用VCS-es的正确"方法是将可变的,不断变化的,自行生成的,不受源代码控制的内容保存在单独的区域中-就像在常规源文件中的单独文件一样简单.区域,您可以告诉VCS忽略它,就像git的.gitignore文件一样.)
  • 对于使用svn的人,他们可以欺骗":存储库本身可以存储在该处(想象一下指向Net的箭头),并且当您正在处理的内容自行编辑时,您只需删除内容并要求它再次将它们检出到您的工作树中.因此,这最终只能是半可见的.但是,使用git时,您会自动在此处拥有存储库 ,因此VCS会看到您已更改了内容,并坚持要求您强迫它放弃更改,然后再进行任何更新.
  • You're using git to clone something just to get some version of it, which you intend not to edit.
  • The thing you're cloning edits itself, in its own source tree, in its normal course of operation. This plays rather badly with git, or indeed most version control systems. (The "right" way to do this with VCS-es is to keep the variable, ever-changing, self-generated, non-source-controlled stuff in a separate area—this can be as simple as separate files in the regular source area, that you can tell the VCS to ignore, as with git's .gitignore files.)
  • For someone using svn, they can "cheat": the repository itself can be stored way over there (imagine arrow pointing off into The Net), and when the thing you're working with edits itself, you just remove things and ask it to check them out again into your work tree. So this winds up being only semi-visible. With git, however, you automatically have the repository right here, so the VCS sees that you have changed things and insists that you force it to throw your changes out, before it can update anything.

有几种(也许很多)解决问题的方法.最好的办法是以上面提到的正确方法"对待事物,但这需要另一端的合作.剩下几个解决方法:

There are several (perhaps many) solutions to the problem. The best would be to treat things the "right way" noted above, but that requires co-operation at the other end. That leaves several work-arounds:

  1. 对git明确:将我的内容清除."

  1. Be explicit to git: "wipe my stuff out."

git reset --hard && git fetch && git merge

reset --hard的意思是清除所有更改". (您可能还需要git clean -fdx来删除构建产品.或者,可以将其保留在此处,并仅重置git知道的那些文件,即,它最初是从克隆步骤结帐中提取的文件.)确定你是真的意思;没有哎呀,等等,我改变了主意"选项.

The reset --hard means "wipe out all my changes". (You may also want a git clean -fdx as well, to remove build products. Or, you can leave them there, and reset only those files git knows about, i.e., the ones it extracted originally from your clone-step checkout.) Be sure you really mean it; this has no "oops, wait, I changed my mind" option.

git fetch && git merge步骤可以缩写为git pull(尽管它们并不完全相同,尤其是在git的旧版本中).这是理解此处发生情况的关键: pull只是fetch,其后是merge..您正在使用git checkout和git的所有版本控制内容,以及何时使用删除文件后,git会提供所有有用的 1 ,并坚持保存您的工作,因为可以肯定的是,您正在尝试对自己的更改进行版本控制,并以某种方式将其与它们合并(他们"就是您fetch来自的人.

The git fetch && git merge step can be abbreviated as git pull (although they're not quite identical, especially in older versions of git). This is a key to understanding what's going on here: pull is just fetch followed by merge. You're using git checkout and all of git's version-control stuff, and when you remove files, git gets all helpful1 and insistent on you saving your work, because it's quite certain you're attempting to version-control your own changes, and meld them in some way with theirs ("them" being whoever you fetch from).

将git的存储库与源代码和构建树分开,就像您根本没有使用版本控制系统一样.特别是,您可以使用镜像(或裸克隆)使git像" SVN.这为您提供了本地存储库,但是(至少对于镜像而言)以一种您从未接触过的方式进行,除了从远程版本进行更新之外:

Keep git's repository separate from your source-and-build-tree, as if you're not using a version control system at all. In particular, you can make git "act like" SVN by using a mirror (or a bare clone). This gives you the repository locally, but (at least for the mirror) in a way that you never touch except to update it from the remote version:

git clone --mirror git://whatever... local-clone.git

然后,使用镜像将最新版本提取到一棵空树中:

Then, use the mirror to extract the latest version into an empty tree:

cd local-clone; git --work-tree=/somewhere/else checkout master

或:

cd /somewhere; mkdir else; cd else
git --git-dir=/path/to/local/clone.git checkout master

(或者,您可以使用git --work-tree=... reset --hardgit --git-dir=... reset --hard将某些文件恢复为原始状态,但是您也可以使用第一种方法.)这里的主要优点是,由于git存储库是距离工作树足够远",没有人会偶然地尝试使用git在/somewhere/else中进行工作,以为他们得到了所有常规的git保证.

(Or, you can use git --work-tree=... reset --hard or git --git-dir=... reset --hard to get some files back to their original state, but then you might as well use the first approach.) The main advantage here is that since the git repository is "far enough away" from the work-tree, no one will accidentally attempt to use git to do work in /somewhere/else, thinking they're getting all the usual git guarantees.

如果使用--mirror方法(现在我认为它可能比第一种方法更多的工作),请注意git fetch将直接更新(镜像)分支.在这种情况下,没有任何内容可以合并,实际上您不能使用镜像来保存您自己的更改:当您运行git fetch --prune(或git remote update -p)进行提取时,它们将丢失来自遥控器的新更改.

If you use the --mirror method (which now I think is probably more work than the first method), note that git fetch will update your (mirrored) branches directly. In this case there's nothing to merge, and in fact you can't use the mirror to hold your own changes: they will be lost when you run git fetch --prune (or git remote update -p) to pick up new changes from the remote.

1 或一些不可打印的形容词. :-)

1Or some less printable adjective. :-)

这篇关于为什么删除有冲突的文件会中断项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆