Understanding Git
Where to start
Git is a very useful tool in the Version Control (VC) category for many reasons.
Many people in software development cannot live without Git or another VC solution.
Understanding Version Control
We all make mistakes, and A LOT of them too. How to prevent mistakes from being permanently solidified as concrete in your code? We have many of these tools!
[UNDO] CTRL + Z
The most well-known version control is CRTL + Z or CMD + Z as this is what everyone uses for everyday computer-related tasks. Even artists rely on this. This simply undoes whatever happened before. Sometimes, the operating system or software is sophisticated enough to have a limited history of previous actions. Some are granular; some are chunks. Nevertheless, this is useful even if you use a VC solution for more serious cases.
Centralized VC Solution
I was recently told about this type of Version Control. Slightly more sophisticated than UNDO, it records much more of the history of the file or directory as well as who made changes, but it allows only one direction to go in and copies of files are tracked completely separately and are considered different. Probably what came before Git.
Git
The modern VC solution. Git is very simple in its structure. You can understand it simply as a list of Commits. Or groups of changes with an ID, and a Parent ID. Programmers would know this as a node on a linked list. As a result of this structure, Git allows comparisons between different Commits by calculating the Delta in code between Commits.
How to Avoid Confusion with Git
How I began
When I first started with Git, I was incredibly confused. I dislike videos and prefer clear and concise written documentation. However, I'm always either getting too much or too little.
The System
Local Vs Remote
The central repository hosted on a server is known as Origin.
When Cloning a repository, that's exactly what the name of the action is implying. You are copying the Remote repository exactly onto a separate environment, most likely your workstation.
Branches
Version Control in Git happens with Branching. When a user creates a branch, the new branch sets the commit ID of the parent branch's most recent commit (PID) as its starting point. Every commit made on that branch can be traced back to its PID. All Deltas are measured against the PID. Every time the parent branch is merged INTO the new branch, the PID changes and becomes the ID of the latest commit of the parent branch, and all Code Deltas are measured once more against the commit at the new PID.
Actions
fetch
By itself, fetch checks the differences in Commits between your local branches and their respective remote branches. If provided the name of a remote branch, the fetch command will measure the Commit Delta between the referred branch and the active branch.
merge
By itself, merge must be used after a fetch command. Without any arguments, the merge will consolidate the changes on the remote version of the branch into your local version, and if there are any conflicts, you will be asked to resolve them.
pull
A combination of fetch and merge in sequence. Without arguments, it will fetch and merge your active remote branch with your active local branch. With a remote branch name specified, the command will fetch and merge the specific branch's Commits that are not in your local branch, into your local branch.
Conclusion
I hope I have clarified Git for someone at least. Please leave any comments if there are any more questions about the basic nature of Git. Otherwise, you can use the git help command to get redirected to the git documentation for hundreds of other useful commands.
Comments
Post a Comment