How To Change Repo Name In Github
Introduction
GitHub is i of the most useful tools in a developer's armory today, with several organizations using Git to control and deploy code. Recently, GitHub has implemented the Conservancy's suggestion and has stopped using the term master when a new repository is initialized. Now, the principal branch is called the main branch, and GitHub stated that they are encouraging projects to switch to branch names that are meaningful and inclusive while making information technology easier for them to apply the new default name. This was carried out after the 2022 protests when the term master was found to be offensive to people.
If you're looking to change the name of your GitHub branch every bit well, and then this web log will help you accomplish merely that in a few unproblematic steps:
Guide to rename co-operative
Note: People with write permissions to a repository tin can rename a branch in the repository. People with admin permissions can rename the default branch.
1. First clone repository to your local.
git clone repo_url
two. Checkout branch which you want to rename. For example, "master" to exist renamed to "chief".
git checkout principal
3. Move your "branch_name_to_be_renamed" to "new_branch_name" –
git branch -thousand master primary
4. Push your new co-operative name to GitHub repo
git push -u origin primary
(Here -u sets the new co-operative as the local default at the same time)
git remote set-head origin main
(This line ensures our local Caput points to our new branch on GitHub)
5. Verify branches and you tin can find origin/HEAD -> origin/chief
git branch -r
6. Go to GitHub and alter your default branch to the newly created branch. If it is non the chief or default co-operative skip this step. To achieve this, become to your repository settings > Branches and select the default co-operative.
7. Delete onetime co-operative. Before taking this step go to your repository on GitHub and verify your new branch appears in the list.
git push origin –delete master
eight. In this step you should have to verify your lawmaking, scripts, automation, integrations for references to the master branch. For example, check files like: travis.yml, .github/workflows/, .circleci/config.yml, etc. and make certain at that place are no external services or links relying or referencing the master branch.
9. Git does not override some native commands similar git init, soyou can create git new using following control:
git config –global alias.new '!git init && git symbolic-ref HEAD refs/heads/main'
Tip: While you are renaming other branches than gear up your origin to the default co-operative. This can be accomplished using step 8, just alter the default branch proper noun.
What team must follow
Inside squad if they take local clone of repository, they must perform post-obit steps:
- Checkout master branch: git checkout master
- Rename it too main: git branch -m master principal
- Go latest commits: git fetch
- Remove existing tracking connections: git branch –unset-upstream
- Create new tracking connections: git branch -u origin/chief
Things to Keep in Mind
Renaming a branch is non terrifying or circuitous.
You lot should always backup your repository for recovery.
Wrapping Up
This guide explained how to successfully rename your branch to a more creative and inclusive proper noun as per GitHub and the Salvation'due south advice. Past post-obit all the steps mentioned above, you should be able to accomplish this without any trouble. Still, if you accept any queries most GitHub or related topics, feel free to get in impact with our DEV It engineers for the info.
You May Besides Like
- Remove Unwanted Files and Folders from GitHub Repository
The post-obit two tabs alter content below.
- Bio
- Latest Posts
Ronak Pandya has 14 years of experience in IT Infrastructure, Project Management, and motivational speaker in highpowered globe of Information technology. He has expertise in CloudOps (AWS, Azure), DevOps (Jenkins, GitHub, Jira), Platform (Windows, Linux), Database (MySQL, MSSQL, PostgreSQL). He also spares his time with family and write poetries. He believes in "Think Differently".
Source: https://www.blog.devitpl.com/how-to-renaming-github-master-branch-to-main-branch/
0 Response to "How To Change Repo Name In Github"
Post a Comment