• Home /
  • Blog /
  • View changes before commit in Git
Git Tutorials

View changes before commit in Git

Usually before committing changes in Git developer verify one last time all changes he did. Normally we use git difftool command in order to do it. In that case git will ask you a question if you want to see changes before opening each file. When the number of changed files are big or when different types of files are changed and not all files should be part of the commit, it may be helpful to filter what types of the file we want to verify and disable message asking about each file.

How to disable message asking if you want to see diff for the file

When providing a -y parameter to git difftool command, git will not ask you any questions and will just open default difftool

#do not ask user confirmation before showing diff for file git difftool -y

How to filter files using wildcards when doing git diff

And when provided filter -- **/*.cs git will open difftool only for files matching wildcards, in this case, C# files only.

#notice space after -- it is required #it matches all folders and subfolders where file extension is *.cs (c#) git difftool -- **/*.cs 
#do not ask for user confirmation for all *.cs files git difftool -y -- **/*.cs  

how to view changes in git before commit

Comments

Yaplex - Freelance developer - white logo on black background

Yaplex is a custom software development company co-founded by full-stack .NET Software developer Alex Shapovalov who lives in Mississauga, ON and provides software development services in Mississauga and GTA.

Contact Information

Mississauga, ON, Canada
Phone: +1 647 328 3809
Email: alex@yaplex.com