Skip to the content ForoHackers
Log inJoin

Version control: start here

Version control
#3349 · · Quote · Report

Version control records every change to a set of files, who made it and why, so you can go back, compare, and work in parallel without overwriting each other. Today that almost always means Git. It is the safety net under every serious project, and the history it keeps is documentation.

Key concepts

  • Commits as snapshots: each commit stores the state of the tree, a message and a link to its parent.
  • Branches: cheap pointers to a line of work; you start one for each idea.
  • Merging and rebasing: two ways to combine lines of work, one keeping the shape of history and one rewriting it.
  • Remotes: other copies of the repository you push to and pull from; every clone holds the full history.
  • Good history: small commits, each with one purpose and a message that says why.

Vocabulary

  • Staging area: where you assemble the next commit.
  • HEAD: the commit you are standing on.
  • Conflict: two changes touch the same lines and a person must decide.
  • Tag: a permanent name for one commit, such as a release.

What to study, in order

  1. Make a repository, commit, branch, merge, and read the log with its graph view.
  2. Cause a merge conflict on purpose and resolve it by hand.
  3. Learn the object model: blobs, trees, commits, and how a branch is just a pointer.
  4. Practise rebasing a private branch, and the rule never to rewrite history others have pulled.
  5. Recover from mistakes with the reflog, revert and bisect.

Related tags

#code-review #ci-cd #open-source #developer-tools

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply