Git & GitHub
Scope
When you are working on a project, you may have two issues:
- if the project is developed in a team, then you need to keep track of the changes made by each member and to share the code in an efficient manner
- version history for the entire project and for every file such that you can revert changes that break the code. You also want to have the freedom of experimenting with new features without worrying about breaking it.
What is Git?
- Git is a version control system, designed to handle everything related to source code management
- Git is used to track changes in the source code, enabling multiple developers to work together
What about GitHub? Are Git and GitHub the same?
- GitHub is a web-based platform that uses Git for version control
- GitHub provides a web-based graphical interface and desktop as well as mobile integration
- GitHub also provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project
- GitHub is used by millions of developers to collaborate and share code
- GitHub is not the same as Git, rather it is built on top of Git, and is a place where you can store your code and collaborate with others
GitHub alternatives
There are a few alternatives to GitHub, such as:
- GitLab
- Bitbucket
- SourceForge
- AWS CodeCommit
- Azure Repos
They have the same goal, but they have different features and pricing plans. GitHub is the most popular one, and that is why we will focus on it.
Creating a GitHub account
- Go to: https://github.com/signup
- Fill in all the required fields
GitHub repositories
- A repository contains all the files of your project, and each revision of it
- A repository may also contain multiple branches and will usually have multiple contributors
Repository branches
- Branches allow contributors to develop features, fix bugs or experiment new ides in a contained area of the repository
- A branch can be created from an existing branch, typically new branches are created from the default branch of the repository
Merging branches
- Merging takes the contents of a source branch and integrates them with the target branch. In this process, only the target branch is changed. The source branch history remains the same
Pull requests
- A pull request is an event that takes place when a contributor is ready to begin the process of merging new code changes with the main project branch. After a peer review, the pull request will be approved or not. If it is approved, then it can be merged with the main project branch. If not, the author must make the requested changes and so on.
CI/CD
- Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each commit is then verified by an automated build, allowing teams to detect problems early
- Continuous Deployment (CD) is a strategy for software releases wherein any code commit that passes the automated testing phase is automatically released into the production environment, making changes that are visible to the software's users
- CD is called Continuous Deployment when the release process is fully automated and Continuous Delivery when the build is automatic but the release is manual (someone has to click a button to deploy the code)
- GitHub Actions is a CI/CD tool that is integrated with GitHub that allows you to automate, customize, and execute your software development workflows right in your repository. This is another benefit of using a source control platform like GitHub. (There are other CI/CD tools, such as Jenkins, Travis CI, CircleCI, etc)