查看GitHub中是否有被删除的部分
see if there is a deleted part in GitHub
当有人不拉最新的 master 然后推送他看到冲突
如果他决定覆盖其他代码,则被覆盖的提交不会显示在文件历史记录中
问题可以在这里看到
https://github.com/robertIsaac/delete-test
在这里你可以看到我添加了第二次提交
https://github.com/robertIsaac/delete-test/pull/1/files
在这里你可以看到我删除了第二个提交并添加了第三个提交
https://github.com/robertIsaac/delete-test/pull/2/files
但转到文件的历史记录
https://github.com/robertIsaac/delete-test/commits/master/delete-test.txt
你只看到第一次和第三次提交,它显示了向文件添加了第一次提交和第三次提交字符串,而第二次提交根本没有显示
这是我复制问题的脚本
# delete-test script
# you need to create a repo named delete-test
# and replace the https://github.com/robertIsaac by your user name in the two lines using them
# the second next two lines can be skipped if its your first time running the script
rm -rf ~/github
rm -rf ~/delete-test
mkdir ~/github
cd ~/github
echo "first commit" >> delete-test.txt
git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/robertIsaac/delete-test.git
git push -u origin master
git pull
cd ~
git clone https://github.com/robertisaac/delete-test.git
cd ~/github
git checkout -b first-branch
echo "second commit" >> delete-test.txt
git add .
git commit -m "second commit"
git push origin first-branch
## go merge with master (no conflict)
cd ~/delete-test
git checkout -b second-branch
echo "third commit" >> delete-test.txt
git add .
git commit -m "third commit"
git push origin second-branch
## go merge and resolve conflict by accepting second-branch changes and deleting the master changes
我的问题是,如果我再次遇到这样的问题,我该如何在不搜索每个拉取请求以查看谁删除了我的代码的情况下抓住它
很有意思,我到现在才知道这个问题。
看起来 git log --follow delete-test.txt
是解决方案。
commit a0d607f5c80f2d9130bd197d9c0af1199515e8cf
Author: robertisaacBBN <robert.isaac@businessboomers.net>
Date: Sat Dec 1 00:46:06 2018 +0200
third commit
commit 168d67c24ec1de7e20c645274f64f151592d938f (origin/first-branch)
Author: robertisaacBBN <robert.isaac@businessboomers.net>
Date: Sat Dec 1 00:45:22 2018 +0200
second commit
commit 6b488fffd4b0581888e0942249a7b81e68d7db4b
Author: robertisaacBBN <robert.isaac@businessboomers.net>
Date: Sat Dec 1 00:45:14 2018 +0200
first commit
感谢原文章作者@https://www.shellhacks.com/git-particular-file-change-history/
当有人不拉最新的 master 然后推送他看到冲突 如果他决定覆盖其他代码,则被覆盖的提交不会显示在文件历史记录中
问题可以在这里看到 https://github.com/robertIsaac/delete-test
在这里你可以看到我添加了第二次提交 https://github.com/robertIsaac/delete-test/pull/1/files
在这里你可以看到我删除了第二个提交并添加了第三个提交 https://github.com/robertIsaac/delete-test/pull/2/files
但转到文件的历史记录 https://github.com/robertIsaac/delete-test/commits/master/delete-test.txt 你只看到第一次和第三次提交,它显示了向文件添加了第一次提交和第三次提交字符串,而第二次提交根本没有显示
这是我复制问题的脚本
# delete-test script
# you need to create a repo named delete-test
# and replace the https://github.com/robertIsaac by your user name in the two lines using them
# the second next two lines can be skipped if its your first time running the script
rm -rf ~/github
rm -rf ~/delete-test
mkdir ~/github
cd ~/github
echo "first commit" >> delete-test.txt
git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/robertIsaac/delete-test.git
git push -u origin master
git pull
cd ~
git clone https://github.com/robertisaac/delete-test.git
cd ~/github
git checkout -b first-branch
echo "second commit" >> delete-test.txt
git add .
git commit -m "second commit"
git push origin first-branch
## go merge with master (no conflict)
cd ~/delete-test
git checkout -b second-branch
echo "third commit" >> delete-test.txt
git add .
git commit -m "third commit"
git push origin second-branch
## go merge and resolve conflict by accepting second-branch changes and deleting the master changes
我的问题是,如果我再次遇到这样的问题,我该如何在不搜索每个拉取请求以查看谁删除了我的代码的情况下抓住它
很有意思,我到现在才知道这个问题。
看起来 git log --follow delete-test.txt
是解决方案。
commit a0d607f5c80f2d9130bd197d9c0af1199515e8cf
Author: robertisaacBBN <robert.isaac@businessboomers.net>
Date: Sat Dec 1 00:46:06 2018 +0200
third commit
commit 168d67c24ec1de7e20c645274f64f151592d938f (origin/first-branch)
Author: robertisaacBBN <robert.isaac@businessboomers.net>
Date: Sat Dec 1 00:45:22 2018 +0200
second commit
commit 6b488fffd4b0581888e0942249a7b81e68d7db4b
Author: robertisaacBBN <robert.isaac@businessboomers.net>
Date: Sat Dec 1 00:45:14 2018 +0200
first commit
感谢原文章作者@https://www.shellhacks.com/git-particular-file-change-history/