These are the basics for how to use git to get you easily started with contributing. We suggest going through the official git manual as a follow-up: Pro Git
Create a fork of the repository and then:
$ git clone [email protected]/YOUR_USERNAME/REPO.git
$ cd REPO
$ git remote add upstream [email protected]:packit/REPO.git
At this point you should have:
$ git remote -v
origin [email protected]:YOUR_USERNAME/REPO.git (fetch)
origin [email protected]:YOUR_USERNAME/REPO.git (push)
upstream [email protected]/packit/REPO.git (fetch)
upstream [email protected]/packit/REPO.git (push)
$ git checkout -b my-new-feature
Pushing this to your fork for the first time is:
$ git push -u origin my-new-feature
If there are new changes added to upstream/main
branch, you need to rebase your branch (to keep our git history clean and
easy to navigate we rebase our branches before merging).
You need to fetch the changes from upstream:
$ git fetch upstream
And then do the rebase:
$ git rebase upstream/main
If there are any conflicts, you need to resolve them manually in the editor (git will tell you this)
and then follow the steps in the output of the command (e.g. after resolving the conflicts git rebase --continue
).
After the rebase, history of the branch is rewritten. Therefore, if the branch is already pushed, git status
will tell
you that the local branch has diverged from the remote branch and you will need to force push the changes (git push -f
).
$ git config --global pull.rebase true
$ git config --global rebase.autoStash true