Working in parallel
Working in parallel is a powerful approach in Git that amplifies development possibilities and allows multiple team members to collaborate seamlessly. With Git's branching and merging capabilities, you can work simultaneously on different features, bug fixes, or experiments without stepping on each other's toes. This collaborative workflow enhances productivity, promotes efficient collaboration, and fuels innovation.
In this part of our tutorial, we will delve into the concept of working in parallel with Git. You will learn how to leverage branches to create independent lines of development, enabling team members to work on separate tasks concurrently.
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.