Jose Robledo
04 March 2025
Let’s say we want to update the guacamole recipe, which we know Alfredo is currently working on.
To create a new branch, called “new_guacamole” there are two possible ways
or
To see local (remote add flag -r
) branches,
If you make changes in the new branch and commit them, they will not modify the main branch of the repository, they will follow a new “timeline” of the repository, which started in an initial “node” commit, but then separated (like branches in a tree) into two working lines.
Let’s say you are satisfied with the new guacamole recipe, and you want to share it back to Alfredo. There are two possible ways.
merge
the branch
new-guacamole
to main, and push the changes to the remote
repository.new-guacamole
branch to the main
branch by performing a pull request
from
new_guacamole
to main
.Sometimes, Git can’t automatically merge changes because the same lines of a file were modified differently in two branches. This is called a merge conflict.
In this case, git will notify you and you’ll need to manually edit the files to resolve the conflict.
We had seen you can also checkout a commit instead of a branch. That is, you can go to that point of the history of the folder. In this case, are are in a detached HEAD state, because any commit made here will not be associated to any named branch anymore. You are now directly referencing to a commit.
If you are in a detached HEAD state, create a new branch and switch to it! (This provides a new name reference for further commits)
Content