0

I have always worked with git and opensrc in a very simple limited way

  • I fork the project in github
  • I git clone my fork to my computer
  • I make some changes on my computer
  • I commit the changes
  • I push to my github fork
  • I created pull request from my github fork to the original project, this works for a single change

But if I make more changes on my computer and commit them and push before the pull request is accepted then they get added to the same pull request. I know this is not ideal so I try and wait for first pull request to be accepted before making further changes but this is not always possible.

So instead I experimented with creating a new branch just to fix one bug. But because this branch was created after I had already made a commit on the master branch any pull requests on this new branch include my master commit as well.

So want I think what I want to do is temporarily go back one commit on master branch, then create new branch, then go forward to that commit on master branch, how do I do that ?

Paul Taylor
  • 13,411
  • 42
  • 184
  • 351

1 Answers1

2

By default, git branch new_branch creates a new branch using the current HEAD. To choose a different starting point, simply provide it explicitly.

git branch new_branch HEAD^
chepner
  • 497,756
  • 71
  • 530
  • 681