Working in parallel
Branching allows us to work in multiple parallel workspaces.
To demonstrate this, let's create two branches, one with the name issue2
and another with the name issue3
. Then switch over to issue2
.
$ git branch issue2
$ git branch issue3
$ git checkout issue2
Switched to branch 'issue2'
$ git branch
* issue2
issue3
main
At this point, this is our history:
Next, add the bold text below to the myfile.txt
file.
Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index
commit: Save the status of an index
And then commit the change.
$ git add myfile.txt
$ git commit -m "append description of the commit command"
[issue2 8f7aa27] append description of the commit command
1 files changed, 2 insertions(+), 0 deletions(-)
This is now our history:
Next, switch to the issue3
branch.
$ git checkout issue3
Switched to branch 'issue3'
The issue3
branch currently has the same history and content as the main branch. It will not include the change we just made because it was committed to the issue2
branch.
Add the bold text below to the myfile.txt
file.
Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index
pull: Obtain the content of the remote repository
And commit the change with the add command.
$ git add myfile.txt
$ git commit -m "append description of the pull command"
[issue3 e5f91ac] append description of the pull command
1 files changed, 2 insertions(+), 0 deletions(-)
This is now our history:
We have added two different lines of text to two different branches in parallel.