2

I have multiple projects in a folder and I want to get latest.

For example:

C:\Projects\Project 1
C:\Projects\Project 2
C:\Projects\Project 3

Normally I would open up Git Bash, direct to one project (e.g. 'cd C:\Projects\Project 1'), then type 'git pull'.
After this, repeat on every other project.

Is there a quicker/shorter/less time consuming way to get latest on all of my projects?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
GIVE-ME-CHICKEN
  • 1,239
  • 3
  • 15
  • 29
  • What do you want to happen when a merge conflict happens? – Ikke Feb 25 '15 at 12:54
  • https://joeyh.name/code/mr/ – Benjamin Bannier Feb 25 '15 at 12:55
  • @Ikke - I am fairly new to this, so not sure what are my options - If a conflict happens, then it would be nice to, skip that one, load the rest that do not have any conflicts, and then at the end of the process, offer a way to resolve those conflicts at the end. || Or even perhaps just skip the ones that have conflicts, get latest on the rest, and at the end of the process, message prompt the user which projects did not 'get latest' and why. – GIVE-ME-CHICKEN Feb 25 '15 at 16:33

2 Answers2

1

Another approach is to declare each of your repos in a parent project repo, as submodules.
You can configure those submodules to follow their respective master branch

cd c:\Projects\Parent
git submodule add -b master Project1 /url/Project1

That way, from the parent repo c:\Projects\Parent, a simple cmmand would update every submodule at once:

git submodule update --remote
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

If the submodule approach does not work for you, you could use a simple script written in Bash:

#!/bin/bash

for dir in */
do
    echo "Updating $dir"
    cd "$dir"
    git pull
    cd ..
done

If you define it as a function, you can even make it reusable for other commands:

function for_all_dirs ()
{
    for dir in */
    do
        echo "Updating $dir"
        cd "$dir"
        $*
        cd ..
    done
}

Call this with for_all_dirs git pull and it will pull in all of the directories.

nwinkler
  • 52,665
  • 21
  • 154
  • 168
  • Just so I understand the process, do I open Git Bash, then 'cd C:\Projects\Project 1', then write, 'for_all_dirs git pull' ? Also, where would I put the bash script? – GIVE-ME-CHICKEN Feb 25 '15 at 16:36
  • you would go to _Projects_ and then run it from there. If you're using Git-Bash, add the function to your `~/.bashrc` file. See here for more details: http://superuser.com/questions/602872/how-do-i-modify-my-git-bash-profile-in-windows – nwinkler Feb 25 '15 at 19:08