Hi, I am trying to add a config file to all my projects in my Git repository. I can do it one by one but I had more than 140 projects in my Git repo, which takes a lot of time to get that done, so I was trying to find a shorter way to add this file to all of my projects at once, is it possible? by writing any script?
Do you mean that you have a bunch of subdirectories under https://github.com/deepu558/some-repo-name that you want to add the same file to? Or do you mean that you have a bunch of repositories under https://github.com/deepu558 that you want to add the same file to?
I mean that I have a bunch of repositories under https://github.com/deepu558 that I want to add the same file to.
There isn’t a built-in way to do this on GitHub. When I’ve needed to do something like this, I’ve built a script to loop through all the repositories listed in a text file and perform the following with each:
- Clone the repository to my local machine if it doesn’t exist already
- Perform a
- Create a new branch based on the default branch
- Copy the file from a given location into the repository
- Commit the change
- Push the new branch to the remote repository
- Launch the link to create a new PR based on the new branch in my default browser
- Wait for me to press a key before moving to the next one
I posted a Ruby script that does a lot of the Git interactions to help get you started.