Can I use git diff on untracked files?

前端 未结 10 1060
你的背包
你的背包 2020-11-27 09:58

Is it possible to ask git diff to include untracked files in its diff output, or is my best bet to use git add on the newly created files and the e

10条回答
  •  离开以前
    2020-11-27 10:42

    usually when i work with remote location teams it is important for me that i have prior knowledge what change done by other teams in same file, before i follow git stages untrack-->staged-->commit for that i wrote an bash script which help me to avoid unnecessary resolve merge conflict with remote team or make new local branch and compare and merge on main branch

    #set -x 
    branchname=`git branch | grep -F '*' |  awk '{print $2}'`
    echo $branchname
    git fetch origin ${branchname}
    for file in `git status | grep "modified" | awk "{print $2}" `
    do
    echo "PLEASE CHECK OUT GIT DIFF FOR "$file 
    git difftool FETCH_HEAD $file ;
    done
    

    in above script i fetch remote main branch (not necessary its master branch)to FETCH_HEAD them make a list of my modified file only and compare modified files to git difftool

    here many difftool supported by git, i configure 'Meld Diff Viewer' for good GUI comparison .

提交回复
热议问题