Using Git effectively
git
is a command-line tool for recording, sharing and collaborating on code.
GitHub is a Microsoft-owned company (and website) that makes it easy to use git
, and adds extra collaboration and security tools on top. They also make GitHub Desktop, a convenient graphical user interface for git.
GitHub provide good guides and documentation about best practices. The hello-world walkthrough is essential reading for new users, and the GitHub flow slideshow summarises some best practice. If you prefer learning via video, there is also a GitHub Youtube Channel.
GitHub workflow🔗
The general workflow for making changes to your code is as follows:
- Create a new branch. A branch is a way for you to record and publish your own changes without breaking things for other people who are using the same code. It is also a good way of collecting changes ("commits") into a meaningful unit that can be reviewed by others.
- Edit/add/delete files in the repo on that branch, committing regularly with informative commit messages.
- Push the changes to GitHub, so that others can view the branch.
- Continue to commit and push changes on that branch until you believe it's ready to be merged back into the main codebase that everyone uses.
- Submit a pull request (PR), requesting that the branch be reviewed by somebody else. A PR is simply a way of viewing, commenting on, and approving code to be merged, "pulled" into the main codebase.
- Watch out for the automated tests passing or failing!
For a more generic overview, see GitHub's own guidance.