Git Alias to chain add, commit, pull, push?

command-line, git

Solution

There is no need to add a conflict check into the alias. If a conflict is detected on `git pull` then it automatically `echo`s out the files that have conflicts and stops. This allows the alias to reduced to the following (multi-line for readability):

git config --global alias.commitall '!func(){ git add . && git commit -aqm "$1" &&
    git pull -q --no-progress && git push -q; }; func'

I have added the `-q` argument to stop the calls from echoing the normal bumpf, but that is preference.

Usage:

git commitall "message goes here"

Problem

What I am interested in doing is creating an alias that adds all files, commits with a message, does a pull, if there are any conflicts stop and show a list of conflicted files, otherwise push. I have already found an alias to list conflicted files (`git config --global alias.conflicts "diff --name-only --diff-filter=U"`), but I have no idea how to integrate the rest of the commands. Is it even possible to create an `if` statement in this format? Pseudo code (multi-line for readability): ``` git config --global alias.commitall '!func(){ git add -A && git commit -am "$1" && git pull && <conflict detection and possible die of command> && git push; }; func' ```

Original source

Related problems