How Does Git Work? - JohnHau/mis GitHub Wiki

Introduction

Git is the world's most popular decentralized version control system. Having a good understanding of Git is essential if you want to code and work on a collaborative software development project.

In this article, you will learn how Git works and how to use its crucial functions.

image

image

The following diagram shows the basic Git workflow: image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

Branching Branching is a feature in Git that allows developers to work on a copy of the original code to fix bugs or develop new features. By working on a branch, developers don't affect the master branch until they want to implement the changes.

The master branch generally represents the stable version of your code, which is released or published. That's why you should avoid adding new features and new code to the master branch if they are unstable.

Branching creates an isolated environment to try out the new features, and if you like them, you can merge them into the master branch. If something goes wrong, you can delete the branch, and the master branch remains untouched.

Branching facilitates collaborative programming and allows everyone to work on their part of the code simultaneously. image

image

image

image

image

image

However, sometimes you may come across merge conflicts.

For example, a conflict occurs if someone decides to make edits on the master branch while you’re working on another branch. This type of conflict happens because you want to merge your changes with the master branch, which is now different from your code copy.

Our detailed guide offers several different methods for resolving merge conflicts in Git. image

image

image

image

image

image

image

Conclusion

You should now have a good grasp of what Git is and how it works. Feel free to create a repository and test out the various features to get comfortable using them.

You can also download our Git commands cheat sheet PDF to have all the commands in one place.