【发布时间】:2015-08-13 14:10:18
【问题描述】:
我经常在 OpenSSL 的 git 存储库中工作。我测试我的更改的其中一件事是通过发出 make clean; make dclean 来获得一个干净的副本。
当我执行git pull 时,git 总是失败,因为所有开发人员的杂物都被dclean 删除(见下文)。当它失败时,git 告诉我“提交你的更改或存储你的更改......”。我对提交、保存或隐藏它们不感兴趣。相反,我想放弃它们。
git abandon 不是命令。放弃更改的命令是什么?
一个相关的问题是How do you discard unstaged changes in git?。但答案是把它们藏起来(如果你阅读了这个问题,你将看不到任何真正的答案answers这个问题)。但我对隐藏或保存它们不感兴趣。我只想放弃他们,这样我就可以git pull 回去工作了。
$ git pull
remote: Counting objects: 2069, done.
remote: Compressing objects: 100% (872/872), done.
remote: Total 2069 (delta 1022), reused 589 (delta 589), pack-reused 608
Receiving objects: 100% (2069/2069), 3.13 MiB | 1.59 MiB/s, done.
Resolving deltas: 100% (1272/1272), done.
From https://github.com/openssl/openssl
c40dba9..e0f9bf1 master -> origin/master
8a09500..d8a2353 OpenSSL-fips-2_0-dev -> origin/OpenSSL-fips-2_0-dev
155ca14..f16093d OpenSSL_0_9_8-stable -> origin/OpenSSL_0_9_8-stable
690d040..aaa654d OpenSSL_1_0_0-stable -> origin/OpenSSL_1_0_0-stable
76b49a8..cc74177 OpenSSL_1_0_1-stable -> origin/OpenSSL_1_0_1-stable
c59bd61..4d9dc0c OpenSSL_1_0_2-stable -> origin/OpenSSL_1_0_2-stable
* [new tag] OpenSSL-fips-2_0_9 -> OpenSSL-fips-2_0_9
Updating c40dba9..e0f9bf1
error: Your local changes to the following files would be overwritten by merge:
crypto/aes/Makefile
crypto/asn1/Makefile
crypto/bf/Makefile
crypto/bio/Makefile
crypto/buffer/Makefile
crypto/camellia/Makefile
crypto/cast/Makefile
crypto/cmac/Makefile
crypto/cms/Makefile
crypto/conf/Makefile
crypto/des/Makefile
crypto/dh/Makefile
crypto/dsa/Makefile
crypto/dso/Makefile
crypto/ecdh/Makefile
crypto/ecdsa/Makefile
crypto/engine/Makefile
crypto/err/Makefile
crypto/evp/Makefile
crypto/hmac/Makefile
crypto/idea/Makefile
crypto/lhash/Makefile
crypto/md4/Makefile
crypto/md5/Makefile
crypto/mdc2/Makefile
crypto/modes/Makefile
crypto/ocsp/Makefile
crypto/pem/Makefile
crypto/pkcs12/Makefile
crypto/pkcs7/Makefile
crypto/pqueue/Makefile
crypto/rand/Makefile
crypto/rc2/Makefile
crypto/rc4/Makefile
crypto/ripemd/Makefile
crypto/seed/Makefile
crypto/sha/Makefile
crypto/srp/Makefile
crypto/stack/Makefile
crypto/ts/Makefile
crypto/txt_db/Makefile
crypto/ui/Makefile
crypto/whrlpool/Makefile
crypto/x509/Makefile
engines/Makefile
Please, commit your changes or stash them before you can merge.
Aborting
【问题讨论】:
-
git clean -df && git checkout --stackoverflow.com/questions/52704/… -
感谢 zedfoxus。需要明确的是,我用
git clone结账,然后去上班。我没有本地副本,因为只有一组带有 OpenSSL 的源。所以我直接从克隆工作。因此,我想放弃更改,而不是重新检查。 (相关:我认为 git 在这里的工作是错误的工具,因为只有一组来源。不需要增加复杂性)。 -
嗨,Jeff,如果您这样做了
git clone,您就可以在系统本地获得整个远程仓库。 Git checkout 不会重新克隆。它在分支之间切换您的本地副本。 Git 是管理 OpenSSL 源代码的好工具。其他时间会详细介绍。 -
如果你使用VS Code,每个文件都有一个按钮可以丢弃更改。
标签: git