- assuming you are working with
git
from a command line - assuming your GitHub username is
username
github.com/sappelhoff/pyprep
isupstream
github.com/username/pyprep
isorigin
(your fork)
- first, you start with forking
upstream
- then, you continue by cloning your fork:
git clone https://github.com/username/pyprep
- you'll have your own
main
branch there
- you'll have your own
- you always want to make sure that your fork's
main
andupstream main
are aligned- to do this, you work with git remotes
- Note: this also means that you NEVER work on
main
(unless you know what you are doing) ... because you want to always be able to SYNC your fork withupstream
, which would mean losing your own work onmain
- use
git remote -v
to list your configured remotes- initially this will only list
origin
... a bit like this maybe:
- initially this will only list
origin https://github.com/username/pyprep (fetch)
origin https://github.com/username/pyprep (push)
- Now you want to add
upstream
as a remote. Usegit remote add upstream https://github.com/sappelhoff/pyprep
- again, do
git remote -v
, it should look like this:
origin https://github.com/username/pyprep (fetch)
origin https://github.com/username/pyprep (push)
upstream https://github.com/sappelhoff/pyprep (fetch)
upstream https://github.com/sappelhoff/pyprep (push)
- Now you can use your
upstream
remote to make sure your fork'smain
is up to date.git checkout main
to make sure you are on yourmain
branch- Make sure you do not have any changes on your
main
, because we will discard them! git pull upstream main
SYNC your fork andupstream
- sometimes there are issues, so to be safe, do:
git reset --hard upstream/main
... this makes sure that both branches are really synced. - ensure with another
git pull upstream main
... this should say "already up to date"
- before working on any feature: always do
git checkout main
andgit pull upstream main
- then make your new branch to work on and check it out, for example
git checkout -b my_feature
- do your work
- submit a pull request
- hope you are lucky and nobody did work in between
- however IF somebody did work in between, we need to rebase. Just follow the steps below
- sync
main
through:git checkout main
andgit pull upstream main
- go back to your branch and rebase it:
git checkout my_feature
and thengit rebase main
Now it could be that you are lucky and there no conflicts ... in that case, the
rebase just works and you can then finish up by force pushing your rebased
branch: git push -f my_feature
... you need to force it, because rebasing
changed the history of your branch. But don't worry, if rebasing "just worked"
without any conflicts, this should be very safe.
In case you are unlucky, there are conflicts and you'll have to resolve them
step by step ... git
will be in rebase mode and try to rebase one commit
after another ... for each commit where conflicts are detected, it'll stop.
Then you have to do: git status
to see conflicting files ... then edit these
files to resolve conflicts ... then git add <filename>
... and then
git rebase --continue
to go on to the next commit, rinse and repeat.
NOTE: the conflict resolution part is the dangerous part that can get very messy and where you can actually lose stuff ... so make backups of your branch before.
After everything is resolved, you can again do git push -f my_feature
.
If you screw up during rebasing and you panic, you can do
git rebase --abort
and start again.
If nothing helps and you just don't know how to resolve the issues and
conflicts that arise during rebasing, just make a new branch:
1. git checkout main
1. git pull upstream main
1. git checkout -b my_feature_2nd_attempt
... and apply your changes manually.
This method is not really a git
workflow, ... but in cases where there are
only few changes, this is often a practical solution.
We follow a semantic versioning scheme. This is implemented via hatch-vcs.
The documentation is build and hosted by https://readthedocs.org/.
Admin credentials are needed to access the setup.
- needs admin rights
- we are using semver (see section on versioning)
- we are using GitHub Actions to deploy
Follow this workflow:
- go to your python environment for
pyprep
- make sure all tests pass and the docs are built cleanly
- update
docs/changelog.rst
, renaming the "current" headline to the new version and updating the "Authors" section. "Authors" are all people who committed code or in other ways contributed topyprep
(e.g., by reviewing PRs, moderating discussions). - commit the change and
git push
to main (or make a pull request). Start your commit message with[REL]
. - make an annotated tag
git tag -a -m "1.2.3" 1.2.3 upstream/main
(This assumes that you have a git remote configured with the name "upstream" and pointing to https://github.com/sappelhoff/pyprep). git push --follow-tags upstream
- make a release on GitHub, using the git tag from the previous step (e.g.,
1.2.3
). Fill the tag name into all fields of the release.
Then the release is done and main has to be prepared for development of the next release:
- add a "current" headline to
docs/changelog.rst
- commit the changes and
git push
to main (or make a pull request)