Text of wiki.squid-cache.org › DeveloperResources › GitHints as Styx crawled it on Nov 18, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Git Hints | Squid Web Cache wiki

🔗 Git Hints This page archives git recipes that may be useful in the context of Squid development. It is not meant as a guide to git or GitHub. Most of the recipes here target developers that will eventually submit pull requests back to the Squid Project. Many later recipes rely on the setup (partially) shown in earlier recipes. Your setup may be different; git-related naming conventions vary a lot. If you start in the middle, make sure you understand what you are doing before copy-pasting any commands! 🔗 When a recipe is missing Use a search engine to solve git and GitHub problems.

Virtually all basic questions about git and GitHub (and many advanced ones) are answered on the web. Git mastery helps, but is not required to do Squid development. Git manipulations required for typical Squid development are hardly rocket science. 🔗 Create your public Squid repository on GitHub Login to GitHub. Navigate to the Squid repository . Click the “Fork” button. If you are a part of an organization, that organization may already have a Squid repository fork that you should use instead. 🔗 Create your local Squid work area Your git work area will be a combination of your public Squid repository (a.k.a.

“origin” remote), the official Squid repository (a.k.a. “upstream” remote), and your private (unpublished) Squid branches. Clone your public Squid repository on GitHub into your local work area. By default, git will refer to your public repository as “origin”. This is where you will publish your development branches. To get the right repository .git address for the first command, click the “clone or download” button while looking at your repository on GitHub.

The “clone or download” button offers https and ssh protocols; for development work, you may find ssh authentication easier to work with. The example below uses an ssh address. You may need to upload your publish ssh key to your GitHub account first. $ git clone git@github.com:YOUR_GITHUB_LOGIN/squid.git $ cd squid $ git remote -v # Should show you the origin repository address Point git to the official Squid repository on GitHub.

These instructions call that repository “upstream”, but the name of the remote is up to you. You will never push into this repository, but you will submit pull requests against it. $ git remote add -m master upstream git@github.com:squid-cache/squid.git $ git remote -v # Should show you the origin and upstream repository addresses $ git remote set-url --push upstream upstream-push-disabled # prevents and highlights accidental pushes Optionally, load git notes to see original Bazaar revision numbers, –fixes URLs, and more co-author names in git logs: $ git fetch upstream refs/notes/commits:refs/notes/commits If you are a part of an organization, that organization may provide its own Squid annotations that you should load instead or in addition to the official ones. 🔗 Start working on a feature or change Most stand-alone code changes need a dedicated git branch.

If you want to submit your changes for the official inclusion, you must create a dedicated branch for each such submission (a.k.a. pull request or PR). Git branches are cheap. Each branch is little more than a named pointer to the latest commit on the branch. These commands assume that your changes are based on the latest official master branch . Make sure your upstream master is up to date: $ git fetch upstream master Create a new local feature branch based on the the very tip of the upstream master.

This example uses “support-foobar” as the branch name. $ git checkout -b support-foobar upstream/master You can now make and commit changes to your local feature branch. 🔗 Compare your changes with the official code To compare with the official code that you have previously fetched: $ git diff upstream/master To compare with the official code as it existed when you created your feature branch: $ fork_point=$(git merge-base --fork-point upstream/master support-foobar) $ git diff $fork_point Use git diff –check … to check for basic whitespace problems. 🔗 Squash all the feature branch changes into a single commit These commands rewrite branch history.

Rewriting history may mess up or even permanently destroy your work! Consider pushing all changes to your GitHub repository before squashing your local tree and do not publish the squashed branch until you are sure it ends up with the same code as the last pushed commit. If you need to both rebase and squash your feature branch, you may use interactive rebase and replace the default “pick” with “squash” commands there.

The resulting squashed commit will get the metadata such as Date from the first feature branch commit, confusing readers and some tools (especially on long-lived feature branches), but you can fix that using something like git commit –amend –date=”$(date)” . Doing two things at once (i.e., squashing and rebasing) is faster when things go smoothly, but it is more difficult to discover and fix problems. Also, rebasing an already squashed branch may reduce the number of conflicts but may also create more complex conflicts.

Pick your poison. Switch to the local up-to-date feature branch you want to squash: $ git checkout support-foobar Find the master commit from which your feature branch originated, either by examining git log support-foobar or by using the following trick (which reportedly fails in some cases): $ fork_point=$(git merge-base --fork-point upstream/master support-foobar) Double check that you found the right forking point before making any changes.

For example: $ git show $fork_point and/or $ git log | less +/$fork_point Undo all feature branch commits up to the forking point while keeping their cumulative results, staged in your working directory: $ git reset --soft $fork_point Re-commit the staged results with a new commit message summarizing all the changes on the feature branch: $ git commit If you need to see your old commit messages, and you have published your unsquashed changes on GitHub as recommended earlier, then you can still easily get them from $ git log origin/support-foobar Double check that the squashed result is identical to the published feature branch: $ git diff --exit-code origin/support-foobar || echo 'Start panicking!' When comfortable, publish your squashed changes, permanently deleting the old feature branch commits: $ git push # will fail, giving you the last change to check its intended destination before you add --force 🔗 Rebase your feature branch to be in sync with the current upstream master These commands rewrite branch history.

Rewriting history may mess up or even permanently destroy your work! Consider pushing all changes to your GitHub repository before rebasing your local tree. If you need to both rebase and squash your feature branch, you may use the interactive rebase command shown below and replace the default “pick” with “squash” commands there. The resulting squashed commit will get the metadata such as Date from the first feature branch commit, confusing readers and some tools (especially on long-lived feature branches), but you can fix that using something like git commit –amend –date=”$(date)” .

Doing two things at once (i.e., squashing and rebasing) is faster when things go smoothly, but it is more difficult to discover and fix problems. Also, rebasing an already squashed branch may reduce the number of conflicts but may also create more complex conflicts. Pick your poison. Make sure your upstream master is up to date: $ git fetch upstream master Switch to the to the local up-to-date feature branch you want to rebase: $ git checkout support-foobar Start the interactive rebase process.

The command below should start your editor so that you can tell git what to do with each of the listed commits. The default “pick” action works well for simple cases. $ git rebase --interactive upstream/master When comfortable, publish y

The rest of this page is on the live site.