How Beginners Should Learn Git

Version control records every change in software — every release, every bug. It runs through the entire lifecycle of software, from birth to death. Please treat every commit with care, and write your commit messages as if you were recording history.

Git is currently the most popular version control system and a great choice. As a competent software developer, you should be proficient in using it. You can construct practice scenarios to work through git commands, such as:

  • Create a repo on GitHub and push code to it. (clone, add, commit, push)
  • Create a new branch dev from main, make changes, then merge the code back into main via a PR. (checkout, pr, branch)
  • Create a new branch dev from main, make changes and commit. Then switch back to main, make changes, and push to the remote branch. Switch back to dev and rebase the commits from main into the current branch. (practice rebase and reset)
  • Create a new branch dev from main, create 7 commits, then squash them into a single commit. (practice using reset or rebase)
  • Create a new branch dev from main, create 7 commits, then: squash the 7th commit into the 1st, drop the 2nd commit, edit only the commit message of the 3rd, edit only the commit author of the 4th, and modify the code in the 6th commit. (practice rebase and how to clean up commit history)
  • Fork a repo, clone it locally, and make changes. After new commits appear on the upstream repo’s main branch, sync your local code with the upstream repo. (practice remote, fetch, rebase)

These are just a few example scenarios — you can write more based on your own needs. It is recommended to practice on the command line, and also to use the command line during your regular development workflow. Avoid relying on the UI provided by your IDE.

Once you have a handle on Git, it’s also worth learning about common Git workflows:

  • Git flow
  • Trunk-based
  • Feature branching
  • Forking Workflow

Learning resources: