How to Automatically Update Another Git Repository After Push

Git hooks are basically glorified shell scripts that execute before or after certain Git operations complete, allowing you to customize the behavior of Git.

The post-receive hook executes when a repository receives changes via a git push from another repository. One clever use of this hook is to automatically update another repository when the origin repository receives changes…


Git visual diff with Vimdiff

Basic git diff

The most commonly used form is simply git diff; this shows the changes that are not currently staged for the next commit. If you’ve already staged changes, git diff –cached will show the difference between the index and the last commit.

Typing git diff branch will show a diff between the current working directory and the named branch whilst git diff –stat shows an overview of changes.

Visial git diff

It’s fairly easy to get Vimdiff working with Git. Git has a lot of options for working with diffs, and one is diff.tool. Also related is the merge.tool setting which can be set to allow Vimdiff to be used as the merge resolution program.

These settings can be passed to Git without changing any configuration files:

git difftool --tool=vimdiff --no-prompt

To tell Git to always use Vimdiff, issue the following commands:

git config --global diff.tool vimdiff
git config --global merge.tool vimdiff

Omit –global if you just want to set these for the repository in the working directory. Now typing git difftool should bring up Vimdiff.

Another useful option is difftool.prompt, this will stop Vim prompting about launching vimdiff:

git config --global difftool.prompt false

If you’re just trying these commands out, then the prompt will seem annoying, but there are cases where you might want to ignore a few files so it can be useful.