Git (on Windows using msysgit) - “compound” command
Question
I need to do several "two-step" or "three-step" commands in Git quite frequently, that require me to also specify a branch name as a parameter - things like:
git checkout (branch name)
git pull origin (branch name)
or stuff like that. I would like to "automate" this into an alias - but a simple Git alias won't do - right?
So how can I do this in a Bash shell script? I am well versed in MS-DOS/Windows batch scripts - but I am a total newbie to Bash.
All the examples of Bash alias with more than one Git command I've seen so far seem to not have any parameters...... but I am jumping back and forth between various branches, so I definitely need to define which branch to check out and update from the central repo...
Any help? Any blog posts or articles that a *nix newbie would understand? Any pointers are highly welcome!
Solution
You can define an alias like this:
[alias]
chepull = !git checkout $1 && git pull origin
You can do:
git chepull branch_name
Note: $1
is intentionally not specified in git pull origin
, but should work as intended.