Like the waves.
Originally written in 2021 as I realized I could make fish abbreviations or shell aliases for most git commands using two letters, e.g. "gl" for git log, but "gp" could feasibly be "git pull" or "git push" Henceforth, I wrote this tool to consolidate both actions into one short command to fit my pattern. "gp" is now either "git push" or "git pull" or a no-op, depending on your git tree and the remote's statuses
gp --help
gp: Pull, push, push new branch. Version 1.4.0
- If there are changes in the remote branch, pull
- If there are changes in the local branch, push
- If there is no remote branch, prompt to push a new branch.
Skip prompt with gp -f
- If the branches have diverged, do nothing.
Force push with gp -f
USAGE: gp [-f|-v|-h|--version]
-f|--force Do not prompt for verification when pushing new branch.
Force push when local and remote branches diverged.
-v|--verbose Show more output.
-h|--help Show this message.
--version Show program version.
To pull, push, or push a new remote branch:
gp
As above, but force push if diverged and do not prompt to push a new remote branch:
gp --force
gp -f
- Download raw.githubusercontent.com/roguh/gp/main/gp.
- Make executable and move to your preferred binary location.
chmod +x gp
sudo cp gp /usr/bin/gp
git clone https://github.com/roguh/gp.git
cd gp
make install
OR
git clone https://github.com/roguh/gp.git
cd gp
make install-to-user
make unit-test-on-linux
To include stricter POSIX shells:
make unit-test-all-on-linux
make unit-test-on-macos
Testing is a semi-manual process. Make sure you have permission to push new branches to the remote repository.
If the test script fails, the tests have failed.
Also read the output to determine if gp
is behaving correctly.
Note the test-integration-all-shells.sh
script runs the test-integration.sh
script using the test shell itself.
make test-on-linux
make test-on-macos
make test-on-strict-posix-shells
Run the following commands:
./tests/test-integration.sh sh
./tests/test-integration.sh dash
./tests/test-integration.sh bash
BASH_COMPAT=31 ./tests/test-integration.sh bash
./tests/test-integration.sh zsh
Tested using GNU coreutils 9.0 in these shells:
- dash 0.5
- bash 5.1
- bash 5.1 in bash 3.1 compatibility mode BASH_COMPAT=31
- zsh 5.8
- yash 2.52
- ksh version 2020.0.0
Not tested on MacOS, yet. It should work fine.
Use shellcheck to check shellscripts.
make check
- I wanted a convenient shortcut for
git pull
andgit push
. I recently created git aliases (and fish abbreviations), e.g.gl
forgit log
, and I wanted to usegp
for eithergit pull
orgit push
depending on the state of the repo. This needed more complex code so I wrote this script and eventually moved it to its own repo. - To demonstrate how I would deploy code. Features:
- Linting and other automated checks.
- Thorough tests.
- Integration tests and a way to run them on many different platforms.
- Unit tests that run on many shells, even on Bash 2.03
- Good documentation.
- GitHub Actions for running tests and code checks.