What exactly is a git commit?
Latest commits point to previous commits.
What exactly is a git branch?
What is the HEAD pointer?
Commit and Tree
git log --decorate
can be used to check this.<aside> 📌 SUMMARY: git commit is a pointer to a snapshot of the directory and git branch is a pointer to one of the commit.
</aside>
How to move the HEAD pointer?
Branch commits always create a new commit pointing back to the initial commit.
git checkout <branch>
will move the HEAD pointer to that branch.<aside> 📌 SUMMARY: Git branches can be switched using git checkout and can create a tree based structure of commits when working on a project.
</aside>
Keep in mind with which branch the changes will get merged with.
Merge conflicts occurs only on editing same part of the code on the same file.
git merge branch_name
.$ git checkout master Switched to branch 'master' $ git merge iss53 Merge made by the 'recursive' strategy.
<div id="footer">
please contact us at [email protected]
</div>
iss53:index.html`
git branch --merged
gives a list of branch merged and using --no-merged
option gives those that are not merged into the current branch that is checked out.<aside> 📌 SUMMARY: Switch to the branch you would like to merge changes to and in case of merge conflicts, you can either accept/reject either one of the code on the branches.
</aside>