I am a Ruby on Rails programming novice and new to VCS as well. I will explain my question with an example:
Scenario: I have created an rails application base using rails new AppName. An empty git repository is created by default with HEAD -> master. I have Staged and commited changes. Now I run git checkout -b new-branch-1. It creates a new branch and checks out to it. Now I made some changes in this branch and commited those changes.
Question 1: Now, If I want to create a new branch and checkout to it, and the branch should have the changes I made in new-branch-1. What command should I run and which branch should I run it from?
Question 2: Does it matter, from which branch I run the command?
P.S: need not to involve remote repos
I tried the same as mentioned above. Just need better clarity.
Q1: To create a new branch and have it include the changes you made in new-branch-1, you can do this:
This command will create a new branch named new-branch-2 based on the current branch new-branch-1. It will copy all the changes from new-branch-1 to the new branch, and then check out to the newly created new-branch-2.
Q2: The branch from which you run the command does not matter. You can be on any branch when executing the git checkout -b command. The new branch will be created based on the specified source branch (in this case, new-branch-1) regardless of the branch you are currently on.