How Git And Github Work Together
Definition: Repository: (A GitHub repository can be used to store a development project. It can contain folders and any type of files (HTML, CSS, JavaScript, Python, Ruby, Java, Scala, etc, Documents, Data, and Images)).
What is Github? GitHub is a code hosting platform for collaboration and version control. GitHub lets Software Engineers work together on projects.
So, how does it all work? Imagine a Software Engineer writing some code in a file that belongs to a folder (repository). He finishes writing his code, tests it, and saves it to Github using Git.
The act of ‘saving’ the code is known as committing(A commit adds the latest changes to [part of] the source code to the repository (folder), making these changes part of the master revision of the repository.
After he commits his code, he then makes it a part of the master revision or whatever version of revision he chooses. The act of making the code a ‘part’ of the master revision or whatever revision he chooses, is known as pushing code.
Software Engineers will push the changes made from their code which is in their local repository(meaning the folder that’s in their computer) to the master revision version or whatever revision he chooses, in Github.
Why do I keep mentioning, ‘or whatever revision he chooses’ ?
Simple, picture a tree like the one below,
This tree has a trunk and multiple branches.
Now how does a tree correlate with Git and Github? Simple, in Git, just like the tree, there are many branches.
What do I mean by branches?
Imagine the master revision being the tree trunk and the other revisions being the branches.
So the Software Engineer will push his code from a local branch(the revision, file and folder he’s been working on from his computer) to the master branch(in Github) but only after he is done writing the code and the code has been tested.
But what if there are multiple Software Engineers working on the same project? Well, simply put, if there are multiple Software Engineers making changes to the same project(repository) they can make what’s known as a pull request in order to push changes they made locally (in their folder) to the master revision.
(A pull request is the heart of GitHub collaboration. With a pull request developers are proposing that changes should be merged (pulled in) with the master revision (master branch).
But why do Software Engineers have to push code to the master revision (master branch)?
Generally, the master revision is what the users will see and use. Not any other revision.
Let me know what you think below!
iOS Engineer - Compliance, Reliability @ QAD Redzone ????
5 年Source control like Git and Github are WAY better than passing files back and forth through email/flash drives/CD’s/floopy disks! Can’t imagine how anyone got things done efficiently before source control!