To set Visual Studio Code as Core Editor for Git. This command requires “code –wait” command working from command prompt, if not, then you may Add code to PATH environment variable and check the “code –wait” command working from command prompt OR you may replace “code” by actual path to code.exe
git config --global core.editor "code --wait"
Once above command is run, you can edit Git config in Visual Studio Code with below command
git config --global -e
Open global config with Visual Studio Code with above command and paste below lines in opened .gitconfig file which will set Visual Studio Code to be used as default tool for git difftool command
[diff]
tool = default-difftool
[difftool "default-difftool"]
cmd = code --wait --diff $LOCAL $REMOTE
To check graphical view of commit history. Press ‘q’ to exit
git log --oneline --graph
Use below command to compare all the files in version before last commit and last commit, make sure you have set Visual Studio Code as default tool as mentioned above:
git difftool HEAD^ HEAD
To create new branch called feature
git branch feature git checkout feature OR git checkout -b feature
To merge above created feature branch to master
git add --all git commit -m "commit message" git checkout master git merge feature
To pull changes from remote repo to local master branch and rebase master branch on the changes in remote repo.
git checkout master git pull --rebase
To revert changes to specific unstaged file
git checkout -q -- <path_of_file>
To see difference between two files
git diff <path_of_file1_tobecompared> <path_of_file2_tobecompared>
To add untracked changes to changes to commit stage
git add --all
To check status of current commits, added changes etc.
git status
To check commit history
git log --oneline --graph
To push changes on master branch to remote repo named origin. Flag -u should be used only when you are pushing local branch to remote branch for the first time.
git push -u origin master