Skip to content

Is there a way to add a new file to all of my projects in my Git Repository at once? #21895

Discussion options

You must be logged in to vote

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:

  1. Clone the repository to my local machine if it doesn’t exist already
  2. Perform a git fetch
  3. Create a new branch based on the default branch
  4. Copy the file from a given location into the repository
  5. Commit the change
  6. Push the new branch to the remote repository
  7. Launch the link to create a new PR based on the new branch in my default browser
  8. 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.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants