어떻게 하면 '깃 (git) 을 제외한 나머지 두 개 사이에 차이를 보이기 diff' 커밋한 커밋한 중간입니까?
수 없이 그 사이의 차이를 묻는 / 2 / 커밋한 커밋한 거의 없다. 단지 스냅샷입니다 커밋한 내용에 대한 리포지토리를. 그 차이를 묻는 것은 두 가지 있습니다. 따라서 중요한 것은 정말 찾고, 뭐 그런?
이에 따라 윌리엄 체리 따기 리베이스 커밋합니다 위에 또 다른 하나의 변동분 얻을 수 있습니다. 즉:
$ git checkout 012345
$ git cherry-pick -n abcdef
$ git diff --cached
$ git log -u -1 abcdef
이 수치는 최근 압스데프 즉시인지 조상, 홀로 보통 그리웠댔지.
물론
$ git diff 012345..abcdef
이러한 두 가지 커밋한 너회들을 보기입니다 차이점.
깃 (git) '에서' 설정 '~' 내 '앨리어스가 /.bashrc 파일의 diff'.
alias gdca='git diff --cached' # diff between your staged file and the last commit
alias gdcc='git diff HEAD{,^}' # diff between your recent tow commits
Not my english 는 네이티브 언어 입력 오류를 좀 주십시오.
깃 (git) 을 사용하여 간단히 2.19, 이후 수 있습니다.
"'git diff 범위 rev1.rev2"'
또는 "'git diff 범위 .rev1 rev2 .rev2 rev1 ~ ~"
내가 잘 보여 주는, diff 는 두 개 사이에 작성했습니까 스크립트입니다 커밋한 unbuntu.
https://gist.github.com/jacobabrahamb4/a60624d6274ece7a0bd2d141b53407bc
#!/usr/bin/env python
import sys, subprocess, os
TOOLS = ['bcompare', 'meld']
def getTool():
for tool in TOOLS:
try:
out = subprocess.check_output(['which', tool]).strip()
if tool in out:
return tool
except subprocess.CalledProcessError:
pass
return None
def printUsageAndExit():
print 'Usage: python bdiff.py <project> <commit_one> <commit_two>'
print 'Example: python bdiff.py <project> 0 1'
print 'Example: python bdiff.py <project> fhejk7fe d78ewg9we'
print 'Example: python bdiff.py <project> 0 d78ewg9we'
sys.exit(0)
def getCommitIds(name, first, second):
commit1 = None
commit2 = None
try:
first_index = int(first) - 1
second_index = int(second) - 1
if int(first) < 0 or int(second) < 0:
print "Cannot handle negative values: "
sys.exit(0)
logs = subprocess.check_output(['git', '-C', name, 'log', '--oneline', '--reverse']).split('\n')
if first_index >= 0:
commit1 = logs[first_index].split(' ')[0]
if second_index >= 0:
commit2 = logs[second_index].split(' ')[0]
except ValueError:
if first != '0':
commit1 = first
if second != '0':
commit2 = second
return commit1, commit2
def validateCommitIds(name, commit1, commit2):
if commit1 == None and commit2 == None:
print "Nothing to do, exit!"
return False
try:
if commit1 != None:
subprocess.check_output(['git', '-C', name, 'cat-file', '-t', commit1]).strip()
if commit2 != None:
subprocess.check_output(['git', '-C', name, 'cat-file', '-t', commit2]).strip()
except subprocess.CalledProcessError:
return False
return True
def cleanup(commit1, commit2):
subprocess.check_output(['rm', '-rf', '/tmp/'+(commit1 if commit1 != None else '0'), '/tmp/'+(commit2 if commit2 != None else '0')])
def checkoutCommit(name, commit):
if commit != None:
subprocess.check_output(['git', 'clone', name, '/tmp/'+commit])
subprocess.check_output(['git', '-C', '/tmp/'+commit, 'checkout', commit])
else:
subprocess.check_output(['mkdir', '/tmp/0'])
def compare(tool, commit1, commit2):
subprocess.check_output([tool, '/tmp/'+(commit1 if commit1 != None else '0'), '/tmp/'+(commit2 if commit2 != None else '0')])
if __name__=='__main__':
tool = getTool()
if tool == None:
print "No GUI diff tools"
sys.exit(0)
if len(sys.argv) != 4:
printUsageAndExit()
name, first, second = None, 0, 0
try:
name, first, second = sys.argv[1], sys.argv[2], sys.argv[3]
except IndexError:
printUsageAndExit()
commit1, commit2 = getCommitIds(name, first, second)
if not validateCommitIds(name, commit1, commit2):
sys.exit(0)
cleanup(commit1, commit2)
checkoutCommit(name, commit1)
checkoutCommit(name, commit2)
try:
compare(tool, commit1, commit2)
except KeyboardInterrupt:
pass
finally:
cleanup(commit1, commit2)
sys.exit(0)