Bash shell scripts to make life easier when using Git.
The scripts allow for:
- automated git commit and push,
- automated git pull.
- The script detects the current git repository, the current branch and the name
of the remote repository, then pushes to the remote repository with the branch
of the same name.
- A silent version of 'commit.sh' which only gives an output if an error occurs.
- Git pull from your remote repository for your current branch.
- A silent version of 'pull.sh' which only gives an output if an error occurs.
- Bash
- git
-
Clone the directory:
git clone https://github.com/declancm/git-scripts.git ~/git-scripts
-
Ensure the scripts executable:
chmod +x ~/git-scripts/*.sh
-
Make sure you have added a remote repository to your desired git directory:
https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories
-
Aliases can be created within ' ~/.bashrc ' (or ' ~/.zshrc ' for ZSH as long as
bash is installed) like so:alias commit='source ~/git-scripts/commit.sh' alias pull='source ~/git-scripts/pull.sh'
From terminal, manually run the shell scripts:
source ~/git-scripts/commit.sh
source ~/git-scripts/pull.sh
A string can be supplied as an argument to create a custom commit message.
source ~/git-scripts/commit.sh "example commit message"
source ~/git-scripts/pull.sh "example commit message"
To get the most benefit from these scripts, create an alias in your .bashrc (or
.zshrc etc.)
The same scripts can be used for vim/neovim:
nnoremap <silent> <leader>gc :!source ~/git-scripts/commit.sh<CR>
nnoremap <silent> <leader>gp :!source ~/git-scripts/pull.sh<CR>