Working with Remotes

7

questions

How do you version releases?

With SemVer: vMAJOR.MINOR.PATCH. MAJOR — breaking changes, MINOR — new functionality without breaking, PATCH — fixes. I mark a release with an annotated tag on a commit in main, and the tag triggers the deploy in CI.

How is origin/main different from main?

main is your local branch that you commit to. origin/main is a remote-tracking branch: a local copy of the server's main as of the last fetch. You don't change it directly; it's updated by fetch and pull.

What does the -u flag do?

git push -u origin <branch> (--set-upstream) remembers the link between the local and the remote branch. After that, git push, git pull and git status (ahead / behind) work without arguments. To check the links — git branch -vv.

What is origin?

The default name git clone gives to the repository you cloned from. It's just a name for a URL: you can rename it or add other remotes, for example upstream for the original repository of a fork.

What's the difference between a lightweight and an annotated tag?

A lightweight tag is just a name pointing to a commit. An annotated tag (git tag -a) is a separate object with an author, date and message, and it can be signed. Releases use annotated tags: git describe and most tools rely on them.

What's the difference between fetch and pull?

git fetch only downloads new commits and updates origin/*; your branches stay as they are — you can look at what arrived first. git pull = fetch + integrating into the current branch (merge, or rebase with --rebase).

Why is –force-with-lease safer than –force?

--force overwrites the remote branch no matter what, even if someone else's commits have appeared there. --force-with-lease first checks that the remote branch is where you last saw it and refuses if someone pushed in the meantime.