비교를 넘어서 Git Diff
나는 git이 Beyond Compare 3를 diff 도구로 시작하는 데 성공했지만 diff를 수행하면 비교중인 파일이로드되지 않습니다. 파일의 최신 버전 만로드되고 다른 것은로드되지 않으므로 Beyond Compare의 오른쪽 창에는 아무 것도 표시되지 않습니다.
Beyond Compare 3과 함께 Cygwin과 함께 git 1.6.3.1을 실행하고 있습니다. 웹 사이트의 지원 부분에서 다음과 같은 스크립트를 사용하여 제안한대로 비교할 수없이 설정했습니다.
#!/bin/sh
# diff is called by git with 7 parameters:
# path old-file old-hex old-mode new-file new-hex new-mode
"path_to_bc3_executable" "$2" "$5" | cat
다른 사람이이 문제에 직면했고 이에 대한 해결책을 알고 있습니까?
편집 :
VonC의 제안을 따랐지만 여전히 이전과 똑같은 문제가 있습니다. 나는 Git을 처음 접했기 때문에 diff를 올바르게 사용하지 않을 것입니다.
예를 들어, 다음과 같은 명령을 사용하여 파일에서 diff를 보려고합니다.
git diff main.css
그러면 Beyond Compare가 열리고 왼쪽 창에 현재 main.css 만 표시되고 오른쪽 창에는 아무것도 표시되지 않습니다. 기본적으로 내가 마지막으로 커밋 한 HEAD와 비교하여 왼쪽 창에서 현재 main.css를보고 싶습니다.
내 git-diff-wrapper.sh는 다음과 같습니다.
#!/bin/sh
# diff is called by git with 7 parameters:
# path old-file old-hex old-mode new-file new-hex new-mode
"c:/Program Files/Beyond Compare 3/BCompare.exe" "$2" "$5" | cat
내 자식 구성은 Diff에 대해 다음과 같습니다.
[diff]
external = c:/cygwin/bin/git-diff-wrapper.sh
추가 래퍼 .sh 파일을 사용하지 않습니다. 내 환경은 Windows XP, cygwin의 git 1.7.1, Beyond Compare 3입니다. 다음은 내 .git / config 파일입니다.
[diff]
tool = bc3
[difftool]
prompt = false
[difftool "bc3"]
#use cygpath to transform cygwin path $LOCAL (something like /tmp/U5VvP1_abc) to windows path, because bc3 is a windows software
cmd = \"c:/program files/beyond compare 3/bcomp.exe\" "$(cygpath -w $LOCAL)" "$REMOTE"
[merge]
tool = bc3
[mergetool]
prompt = false
[mergetool "bc3"]
#trustExitCode = true
cmd = \"c:/program files/beyond compare 3/bcomp.exe\" "$LOCAL" "$REMOTE" "$BASE" "$MERGED"
그런 다음 $ git difftool 을 사용 하여 비교하고 $ git mergetool 을 사용하여 병합합니다.
trustExitCode 정보 : 사용자 지정 병합 명령의 경우 병합의 성공 여부를 확인하는 데 병합 명령의 종료 코드를 사용할 수 있는지 여부를 지정합니다. 이것이 true로 설정되지 않은 경우 병합 대상 파일 타임 스탬프가 확인되고 파일이 업데이트 된 경우 병합이 성공한 것으로 간주됩니다. 그렇지 않으면 사용자에게 병합 성공을 표시하라는 메시지가 표시됩니다.
Posh-Git 의 저자 인 @dahlbyk 에게 자신의 구성을 요점으로 게시 한 것에 감사드립니다 . 구성 문제를 해결하는 데 도움이되었습니다.
[diff]
tool = bc3
[difftool]
prompt = false
[difftool "bc3"]
cmd = \"c:/program files (x86)/beyond compare 3/bcomp.exe\" \"$LOCAL\" \"$REMOTE\"
[merge]
tool = bc3
[mergetool]
prompt = false
keepBackup = false
[mergetool "bc3"]
cmd = \"c:/program files (x86)/beyond compare 3/bcomp.exe\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\"
trustExitCode = true
[alias]
dt = difftool
mt = mergetool
Beyond Compare 2에 대해 다음 명령을 실행합니다.
git config --global diff.tool bc2
git config --global difftool.bc2.cmd "\"c:/program files (x86)/beyond compare 2/bc2.exe\" \"$LOCAL\" \"$REMOTE\""
git config --global difftool.prompt false
Beyond Compare 3에 대해 다음 명령을 실행합니다.
git config --global diff.tool bc3
git config --global difftool.bc3.cmd "\"c:/program files (x86)/beyond compare 3/bcomp.exe\" \"$LOCAL\" \"$REMOTE\""
git config --global difftool.prompt false
그런 다음 git difftool
공식 문서 가 나를 위해 일했습니다.
Here is my config file. It took some wrestling but now it is working. I am using windows server, msysgit and beyond compare 3 (apparently an x86 version). Youll notice that I dont need to specify any arguments, and I use "path" instead of "cmd".
[user]
name = PeteW
email = petew@petew.com
[diff]
tool = bc3
[difftool]
prompt = false
[difftool "bc3"]
path = /c/Program Files (x86)/Beyond Compare 3/BComp.exe
[merge]
tool = bc3
[mergetool]
prompt = false
keepBackup = false
[mergetool "bc3"]
path = /c/Program Files (x86)/Beyond Compare 3/BComp.exe
trustExitCode = true
[alias]
dt = difftool
mt = mergetool
The Beyond Compare support page is a bit brief.
Check my diff.external answer for more (regarding the exact syntax)
Extract:
$ git config --global diff.external <path_to_wrapper_script>
at the command prompt, replacing with the path to "
git-diff-wrapper.sh
", so your~/.gitconfig
contains
-->8-(snip)--
[diff]
external = <path_to_wrapper_script>
--8<-(snap)--
Be sure to use the correct syntax to specify the paths to the wrapper script and diff tool, i.e. use forward slashed instead of backslashes. In my case, I have
[diff]
external = c:/Documents and Settings/sschuber/git-diff-wrapper.sh
in
.gitconfig
and
"d:/Program Files/Beyond Compare 3/BCompare.exe" "$2" "$5" | cat
in the wrapper script.
Note: you can also use git difftool
.
it looks like BC3 only supports 3 way merge for PRO Edition. http://www.scootersoftware.com/moreinfo.php?zz=kb_editions
Please notice you make a wrong path of $2. because you are under Cygwin but BC3 not, so you should specify a full path for it. such as "d:/cygwin$2"
Please refer my git-diff-wrapper.sh here:
$ cat ~/git-diff-wrapper.sh
#!/bin/sh
echo $2
echo $5
/cygdrive/c/Program\ Files\ \(x86\)/Beyond\ Compare\ 3/BCompare.exe "d:/programs/cygwin$2" "$5"
Good luck.
Update for BC4 64bit: This works for Git for Windows v.2.16.2 and Beyond Compare 4 - v.4.2.4 (64bit Edition)
I manually edited the .gitconfig file located in my user root "C:\Users\MyUserName" and replaced the diff/difftool and merge/mergetool tags with
[diff]
tool = bc
[difftool "bc"]
path = 'C:/Program Files/Beyond Compare 4/BComp.exe'
[difftool "bc"]
cmd = \"C:/Program Files/Beyond Compare 4/BComp.exe\" \"$LOCAL\" \"$REMOTE\"
[difftool]
prompt = false
[merge]
tool = bc
[mergetool "bc"]
path = 'C:/Program Files/Beyond Compare 4/BComp.exe'
[mergetool "bc"]
cmd = \"C:/Program Files/Beyond Compare 4/BComp.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"
http://rubenlaguna.com/wp/2010/08/05/visual-difftool-cygwin-git/ has a solution that I adopted to work for BeyondCompare: http://gist.github.com/564573
The difference is in the exe being called: set it up to call bcomp.exe and it'll work fine. Configure your environment to call bcompare.exe and you'll end up with the side of the comparison taken from your revision system being empty.
Run these commands for Beyond Compare 3(if the BCompare.exe path is different in your system, please replace it according to yours):
git config --global diff.tool bc3
git config --global difftool.bc3.cmd "\"c:/program files (x86)/beyond compare 3/BCompare.exe\" \"$LOCAL\" \"$REMOTE\""
git config --global difftool.prompt false
Then use git difftool
If you are running windows 7 (professional) and Git for Windows (v 2.15 or above), you can simply run below command to find out what are different diff tools supported by your Git for Windows
git difftool --tool-help
You will see output similar to this
git difftool --tool=' may be set to one of the following:
vimdiff vimdiff2 vimdiff3
it means that your git does not support(can not find) beyond compare as difftool right now.
In order for Git to find beyond compare as valid difftool, you should have Beyond Compare installation directory in your system path environment variable. You can check this by running bcompare from shell(cmd, git bash or powershell. I am using Git Bash). If Beyond Compare does not launch, add its installation directory (in my case, C:\Program Files\Beyond Compare 4) to your system path variable. After this, restart your shell. Git will show Beyond Compare as possible difftool option. You can use any of below commands to launch beyond compare as difftool (for example, to compare any local file with some other branch)
git difftool -t bc branchnametocomparewith -- path-to-file
or
git difftool --tool=bc branchnametocomparewith -- path-to-file
You can configure beyond compare as default difftool using below commands
git config --global diff.tool bc
p.s. keep in mind that bc in above command can be bc3 or bc based upon what Git was able to find from your path system variable.
For whatever reason, for me, the tmp file created by git diff was being deleted before it opened in beyond compare. I had to copy it out to another location first.
cp -r $2 "/cygdrive/c/temp$2"
cygstart /cygdrive/c/Program\ Files\ \(x86\)/Beyond\ Compare\ 3/BCompare.exe "C:/temp$2" "$5"
For MAC after doing lot of research it worked for me..! 1. Install the beyond compare and this will be installed in below location
/Applications/Beyond\ Compare.app/Contents/MacOS/bcomp
Please follow these steps to make bc as diff/merge tool in git http://www.scootersoftware.com/support.php?zz=kb_mac
For git version 2.15.1.windows.2 with BC2.exe.
The config below finally works on my machine.
[difftool "bc2"] cmd = \"c:/program files/beyond compare 2/bc2.exe\" ${LOCAL} ${REMOTE}
Windows 10, Git v2.13.2
My .gitconfig. Remember to add escape character for '\' and '"'.
[diff]
tool = bc4
[difftool]
prompt = false
[difftool "bc4"]
cmd = \"C:\\Program Files\\Beyond Compare 4\\BCompare.exe\" \"$LOCAL\" \"$REMOTE\"
[merge]
tool = bc4
[mergetool "bc4"]
path = C:\\Program Files\\Beyond Compare 4\\BCompare.exe
You may reference setting up beyond compare as difftool for using git commands to config it.
참고URL : https://stackoverflow.com/questions/2069490/git-diff-with-beyond-compare
'Programming' 카테고리의 다른 글
루비에서 클래스와 Klass의 차이점은 무엇입니까? (0) | 2020.08.11 |
---|---|
Mac / OS X에서 / var / lib / docker는 어디에 있습니까? (0) | 2020.08.11 |
Java의 Arrays.sort 메소드가 다른 유형에 대해 두 가지 다른 정렬 알고리즘을 사용하는 이유는 무엇입니까? (0) | 2020.08.11 |
bash에서 변수가있는 별칭 (0) | 2020.08.11 |
PHP YAML 파서 (0) | 2020.08.11 |