Common Git Actions
How to contribute to a project via Pull Requests (PR)
- Fork the upstream repository into a personal one from the Gitea interface
- Clone the personal repository
- commit/push to your personal repository, then you are ready to create a *pull request*
- From the web interface, go to your forked repository page and click on `pull request`
- From the command line, there is the `git request-pull` command (`git request-pull --help` for details)
- Or you can use the URL that the git command will output when you `git push`. Something like
remote: remote: Create a new pull request for 'andrea.dellamico:master': remote: https://code-repo.d4science.org/InfraScience/ansible-playbooks/compare/master...andrea.dellamico:master remote:
The above URL will get you directly to the pull request interface.
How to work on your (forked) repository
1. If you already checked out the upstream and want to work on the fork instead.
$ git remote rename origin upstream $ git remote add origin YOUR_FORKED_REPOSITORY_URL $ git fetch origin $ git branch --set-upstream-to=origin/master master
At this point, your local branch master is tracking the remote branch master of the forked repository.
Make sure that you are on your master branch:
$ git checkout master
Now you can make your changes and push them to the forked repo with:
$ git push origin
2. If you are starting from a fresh clone of your fork
The private fork must be linked to the upstream one (this command must be executed once):
$ git remote add upstream ORIGINAL_REPOSITORY_URL
Fetch all the branches of upstream into remote-tracking branches, such as upstream/master:
$ git fetch upstream
Make sure that you are on your master branch:
$ git checkout master
Rewrite your master branch so that any commits of yours that aren't already in upstream/master are replayed on top of that other branch:
$ git rebase upstream/master
Last, push to your fork:
$ git push origin master
If you want to to sync all the remote branches, run
$ git remote update
Pull the upstream changes into your forked repository
$ git pull upstream master
Back to the CI guide.