Auto-generate/update files when creating/switching branches

I’m hoping someone will be able to help me with this as I cant seeem to find any documentation or mention of this anywhere.

I would like to have a file within my repo which will be common to every branch and follow the same template but with different contents depending upon the branch.

In my case I would like to keep branch details like the branch name and owner in a format which is predefined.

For example, branchDetails.txt would have:

branch name : %BRANCH_NAME%

owner : %OWNER_NAME%

I am wondering if there is a way to have github automatically update a template file within the repo to create a local version for each branch. I would then add this to a .gitignore file to ensure I never overwrite the template.

The file would have to be updated when a new branch is created and also when I switch working branches within sourcetree or using gitbash.

If github cant automatically do this, can it run a batch file which I could create that would update this file for me when I create a branch or switch branches.

Any help on this woudl be great thanks.

Jonny

Hi @jonathanpzflex,

This post was moved to a different board that fits your topic of discussion a bit better. This means you’ll get better engagement on your post, and it keeps our Community organized so users can more easily find information.

As you’ll notice, your Topic is now in the How to Use Git and GitHub board. No action is needed on your part; you can continue the conversation as normal here.

Let me know if you have any other questions or if I can help with anything else.

Cheers!

Thanks @that-pat. As you can probably tell this is my first post so I havent spent much time in the forums. 

No worries at all! We’re glad to have you and I hope you get the answer that you’re looking for. :smileyvery-happy: