

It makes it possible to view the staged changes and the files not. $ git diff -cached # Can be used to show difference after adding the files The git status command is run to show the state of the working directory and the staging area. But if you want to show the changes which is added or stagged then you need to provide extra options that will let git know that you are interested in stagged or added files diff.
GIT STATUS STAGED CODE
gitconfig for VS Code as both diff tool and merge tool: Ĭmd = code -wait -diff \"$LOCAL\" \"$REMOTE\"īy default git diff is used to show the changes which is not added to the list of git updated files. Here are example entries in my global user. gitconfig in your default Git editor with git config -e -global. gitconfig in your home directory,such as ~ in Unix or normally c:\users\ on Windows). gitconfig file, either through git commands that change it behind the scenes, or editing it directly. Now if you modify the file and do git status, it will show that the file has been modified and not staged for commit and also it will show that the file. Part of setting up a difftool involves changing the. gitconfig entries for vscode as diff/merge tool
GIT STATUS STAGED HOW TO
Or, see the difftool man page for how to configure git to use a different default visual diff tool.Įxample. To use a visual git tool other than the default, use the -t option: $ git difftool -t > Or to look at the diff of a particular file that is staged in the Index: $ git difftool -y -staged >įor all the options, see the man page: $ git difftool -help In this case it will pull up each file in the visual diff tool, one at a time, bringing up the next one after the tool is closed. You Can Always Use difftool in place of diff in git commandsįor all your visual diff needs, git difftool will work in place of any git diff command, including all options.įor example, to have the visual diff tool launch without asking whether to do it for each file, add the -y option (I think usually you'll want this!!): $ git difftool -y -staged Therefore, you will need to close each file in order to see the next one. every time a file is processed by diff), it will launch the default visual diff tool (in my environment, this is VS Code, using the code executable).Īfter the tool launches, the git diff script will pause until your visual diff tool is closed. This will do the same this as git diff -staged, except any time the diff tool is run (i.e. For those who prefer a visual representation of the staged file differences, there is a script available within git which launches a visual diff tool for each file viewed rather than showing them on the command line, called difftool: $ git difftool -staged

The default answer will spit out the diff changes at the git bash (i.e. The top answers here correctly show how to view the cached/staged changes in the Index: $ git diff -cached USING A VISUAL DIFF TOOL The Default Answer (at the command line)
