Skip to content

Git usage and troubleshooting

Guillaume Gelin edited this page Aug 24, 2021 · 2 revisions

Undo mistakes

If your git history is really messed up and you don't know how to revert your changes, you can still use the reflog as a last resort.

  • git reflog will show you the history of your git actions so that you can find the last good state.
  • git reset HEAD@{#} will send you back to that state.

Download a fork

Click the Fork button on the top right of GitHub, then run git clone git@github.com:qtile/YOUR-USERNAME/qtile.git

Commit and push changes

⚠️ Please read how to write good commit messages.

Create a branch for your modifications with git checkout -B YOUR-BRANCH, do your changes, and push them:

git commit -am "Good commit message"
git push origin YOUR-BRANCH

Merge commits from upstream

  • git remote add upstream https://github.com/qtile/qtile.git to add the upstream repository as a remote (you only need to do this once).
  • git checkout master to switch to the master branch.
  • git pull upstream master to get the latest upstream changes.
  • git checkout - to go back to your previous branch (or git checkout YOUR-BRANCH).
  • git rebase master to rebase your changes on top of the latest upstream changes.

If you have conflicts that you don't feel comfortable resolving yet, you can still abort the rebase with git rebase --abort.

If not, you can now push the freshly updated branch with git push --force-with-lease origin YOUR-BRANCH

Squash commits

If you want to group multiple commits into one, follow the same steps as above but run git rebase -i master instead of git rebase master.

In the interactive menu, change all but the first commit from pick to s or squash.

Tips and tricks

  • Don't make changes on your master branch. Create another branch and use master as a reference point.
  • git log --color --graph --abbrev-commit --all to check commit SHAs.