isacikgoz / gitbatch

manage your git repositories in one place
MIT License
1.54k stars 53 forks source link

Feature request: batch branch checkout #72

Closed hendricha closed 5 years ago

hendricha commented 5 years ago

At my workplace we have a rather large project, that contains 10+ repositories (don't ask, not my idea), and sometimes when a larger feature is being implemented, we have to work in multiple repositories, therefore they all will have the dedicated feature branch. What I would like is the option to batch switch to a same named branch in multiple repositories. eg like this: Go into Branch Switch mode -> select relevant repositories like in other modes -> Start either opens a branch list (that shows all common branch names in selections) or there is a simple text input -> this check out that branch in all selected repositories

isacikgoz commented 5 years ago

Thanks for the feedback @hendricha. I guess this is a very specific request but I want it to stay here for a while to listen more ideas from others.

Nevertheless I wrote a basic script to save you for a while. Just put your directories of the repositories into the script.

#!/bin/bash
declare -a arr=("dir1" "dir2" "dir3") #here you will place your dirs
for d in "${arr[@]}"
do
  echo "$d checkout to $1"
  cd $d
  git checkout $1
done

Let's say you put this a file named checkoutall.sh example usage would be:

$ ./checkoutall.sh feature_branch

ps: don't forget to give execution rights to checkoutall.sh by running chmod +x checkoutall.sh command.

hendricha commented 5 years ago

Thanks, you shouldn't have. :D I actually have a similiar script already, I just hoped it could be added to (the otherwise really cool) gitbatch. Anyways, I'm cool if you don't want to add the feature, thanks for answering. :)

isacikgoz commented 5 years ago

I am considering to add this feature, but I need scenarios that explain me how it should work. I also found it useful after I discussed with some of my colleagues.

isacikgoz commented 5 years ago

Hey @hendricha, I've just implemented this and it's merged to master. Also, feel free to open a new issue if you need another feature.

The usage is:

mhagnumdw commented 3 years ago

@isacikgoz, thanks for the answer above! I was looking for it.

If the branch does not exist, is it possible to prevent it from being created?