1

I had this problem:

I wanted to pull different repositories with a 'homemade' command in Linux (through an alias).

So, the problem was: I have a repoA, repoB, repoC. With one command I want to pull all of them and I want to print which repos are pulled.

I was close to put a question here but then I found the solution and I wanted to share it with you.

desmond13
  • 2,913
  • 3
  • 29
  • 46

1 Answers1

1

What I did was:

cd 
gedit .bashrc

In the bashrc file I added the following alias:

(updaterepos is the command you wish to type to update all the repos and of course you can choose one that you like more)

alias updaterepos='echo Performing a git pull of the following repositories: && echo ---repoA && echo ---repoB && echo ---repoC && echo && cd /pathToRepoA && git pull && cd /pathToRepoB && git pull && cd /pathToRepoC && git pull && cd'

I hope this will help someone with my same problem.

desmond13
  • 2,913
  • 3
  • 29
  • 46
  • 1
    Nice solution. You might even want to write this as a stand-alone script that is on your PATH. Reasons may include that aliases should probably be shorter in general/fewer statements, and that a script would be easier to modify and extend in the future. – Micah Smith Jan 12 '15 at 16:45
  • What do you mean by writing a script and setting the path accordingly to include my script? Thanks for the help. – desmond13 Jan 12 '15 at 17:23
  • 1
    In a separate file, named `updaterepos.sh` for example, include the commands in your alias as separate lines. Then, if you save the file in `/usr/local/bin/`, or another directory on your `$PATH`, you can run it from the command line just as you would call the alias. See http://www.panix.com/~elflord/unix/bash-tute.html for example. – Micah Smith Jan 12 '15 at 20:48
  • As a hybrid solution, you can put these commands in a script that is run from the git alias: `git config --global alias.dostuff '!sh dostuff.sh'`. See https://stackoverflow.com/a/1309674/464188 – Bucket Jul 11 '19 at 15:50