How to move files from master to main branch in git?

Member

by larissa , in category: Third Party Scripts , 10 months ago

How to move files from master to main branch in git?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by jasen , 10 months ago

@larissa 

To move files from the master branch to the main branch in Git, you can follow these steps:

  1. Make sure you are currently on the master branch by running the command:
1
git checkout master


  1. Create a new branch named "main" from the current state of the master branch by running the command:
1
git checkout -b main


  1. Add the files you want to move to the main branch by running the following command for each file:
1
git add <file_name>


  1. Commit the changes to the main branch by running the command:
1
git commit -m "Move files to main branch"


  1. Push the changes to the main branch on the remote repository by running the command:
1
git push origin main


  1. Optionally, you can also delete the files from the master branch by running the command:
1
2
3
git rm <file_name>
git commit -m "Delete files from master branch"
git push origin master


By following these steps, you can move files from the master branch to the main branch in Git.

Related Threads:

How to reset to the main branch in git?
How to pull from master branch with git?
How to rebase git branch on master?
How to protect the master branch in git from merging?
How to switch between master and a new feature branch using git?
How to change the main branch in bitbucket?