简体   繁体   中英

Move all files from master to another branch in Git

I started working on a new project and from the beginning I pushed all my commits to master. But now I think I should've used another branch for development and stored my code there and only have the production build in my master.

Is there any way I can move all my files from master to a new branch?

Yes.

Create a branch on the current commit using git branch <whatever> . Then, run git log , and identify which commit is the latest "production" version (probably where you started working). git checkout that commit, and then git branch -f master to make the local master branch point there, and git push -f origin master to update the origin. If you work collaboratively with other people on this repository make sure to update them - force pushing is a destructive action and might cause issues , see this SO question .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM