How do I move the contents of my master branch to a new Git branch?

I’ve been making some vast changes on the master branch of my Git repository. I’m pretty new to Git and so I’m wondering:

How can I move my current master branch to a new branch and recreate my master branch from scratch for a particular folder of files?

  • What does caret bang (^!) after the commit hash do when calling git diff?
  • How to run ./ in windows Git shell?
  • Heroku commands on Cygwin hangs
  • Can I have git gui and git bash and eclipse git plugin looking at same repo simultaneously?
  • Which PIP Returns Global Instead of VirtualEnv
  • How to import a GIT non-Eclipse Java project into Eclipse?
  • As an example, I have another folder, like new_stuff, that contains the new files to be added to the master branch, and that old master is a new branch named old_master.

  • How do I completely nuke a file from a git repo?
  • Use Bitbucket Private Repository With Carthage That Ask For Passwords
  • Setting gc.refLogExpire
  • Git Hist Alias Problems
  • Which files generated by Autotools should I keep in version control repository?
  • GitHub API to Create a File
  • 3 Solutions collect form web for “How do I move the contents of my master branch to a new Git branch?”

    Within the directory of the repository, in the command line type the following:

    git branch -m master old_master
    git branch master

    This should be enough 🙂

    Use git branch -m master old_master to rename master to something else. Then do something like git checkout -b master HEAD~2 to create the new master as per your needs ( in this case till the 2nd commit from previous HEAD ) Now add / replace the folder new_stuff and commit in master

    git checkout master; git reset --hard f1eb786

    worked fine for me and seems less intrusive than deleting master temporarily.

    Git Baby is a git and github fan, let's start git clone.