Here are some great resources for learning how to use Git and GitHub. There’s more here than any one person will need, so just learn what will be helpful to you in the very near future.
- Watch these short videos: Version control with Git and GitHub by freeCodeCamp.
- Check out Better Explained’s guides to version control and Git, or the Learn X in Y minutes guide to Git.
- Consider starting with a Git client with a graphical interface, such as GitHub Desktop, GitButler, or Sublime Merge. They make the most commonly used features of Git easier to use without preventing you from learning more about Git.
- Read some of this free online book, but only the parts that you will use very soon: Pro Git by Scott Chacon and Ben Straub.
- Bookmark Dangit, Git!?! for when you make mistakes with Git.
- How to Write a Git Commit Message by cbeams.
- What are some examples of commonly used practices for naming git branches? - Stack Overflow
Git workflows
There are many different workflows that can be used with Git. A great example is GitHub flow, by GitHub. A workflow I sometimes use is very similar:
- Use
git pull
to make sure your local copy of the code is up-to-date. - Create a new branch with a descriptive name and
git switch
to the branch. - Make commits on your branch.
- When your commits are ready to be merged into the main branch, use
git fetch
and thengit status
to make sure your local copy of the code is up-to-date. If not, switch to the main branch, pull, switch to your branch, and either rebase or merge the main branch into your branch (merge if commit order matters, rebase otherwise). - Push your branch.
- Make and accept a pull request on GitHub between the two branches.
- Delete your branch both locally and on GitHub.
When you’re waiting for a pull request to be approved but have more work to do, create a new branch off the unmerged branch, not main.
Another example of a Git workflow with a different use-case is covered in A successful Git branching model by Vincent Driessen.
further reading
- you can create custom Git subcommands, such as this one for viewing commit history as a compact graph
- “private” repositories on GitHub are not necessarily private
- So You Think You Know Git by Scott Chacon
- for solo projects, how to remove an accidentally pushed file from a git repo history by Moshe Zada
- Commit Often, Perfect Later, Publish Once: Git Best Practices by Seth Robertson
- My favourite Git commit by David Thompson.
- Git Pathspecs and How to Use Them by Adam Giese.
- version numbers
- Semantic versioning is commonly used and is covered in Versioning (by datasift) and by semver.org
- CalVer is another versioning convention based on the calendar
- tagging
- Lets start tagging! by Nageswaran introduces tagging with Git
- Proper use of Git tags by Dan Aloni briefly covers how to avoid some common mistakes and challenges
- Git Basics - Tagging (part of Pro Git by Scott Shacon and Ben Straub) goes into detail
- How HEAD works in git by Julia Evans
- Creating a GPG key for signing Git commits
- git-branchless: High-velocity, monorepo-scale workflow for Git