0

I cloned a bunch of git repos on another let's say laptop, but now my application which requires all of them doesn't work the same as on the initial laptop.

Assuming on the initial one all the repos are located in the folder ~/, is there any command to list the active branch of each package in this folder ?

Regards

phd
  • 82,685
  • 13
  • 120
  • 165
mmmmm
  • 81
  • 5
  • Have you considered using a dependency management system for your language? For example, with `pip` in python, you create a `requirements.txt` file to define your dependencies. These can include external git repos. Most other common programming languages have similar tools. – Code-Apprentice Feb 20 '19 at 21:15
  • is it like cmake ? – mmmmm Feb 20 '19 at 22:33
  • Yes, you should be able to do something similar with cmake by writing rules to clone dependent repos and checkout the correct branch if necessary. Writing such a script will help you create reproducible builds rather than relying on performing the correct steps by hand. – Code-Apprentice Feb 20 '19 at 22:38
  • 2
    With Git 2.30 (Q4 2020), you now have the [new `git for-each-repo` command] (https://stackoverflow.com/a/65766304/6309): it can help executing a command in each registered repository. – VonC Jan 17 '21 at 21:49

1 Answers1

4

Combine find with git branch and have it print the git repo directory and the current branch name.

find /path/to/root/folder -type d -name '.git' -exec echo {} \; -exec git -C {} branch \;

Jack
  • 106
  • 6