Line 23: | Line 23: | ||
When you first get started, you won't have commit access to the git repos for docs. You'll need to create your own copy, called a "fork". To do this, | When you first get started, you won't have commit access to the git repos for docs. You'll need to create your own copy, called a "fork". To do this, | ||
# Go to the Pagure repo you want to fork (for example https://pagure.io/fedora-docs/quick-docs/) | # Go to the Pagure repo you want to fork (for example https://pagure.io/fedora-docs/quick-docs/). We will refer to this as the ''upstream'' repo from now on. | ||
# Click the '''Fork''' button at the top. | # Click the '''Fork''' button at the top. | ||
{{admon/note|Forks don't magically stay in sync|You will need to keep your fork up-to-date with the official repo. This is covered later in this document.}} | {{admon/note|Forks don't magically stay in sync|You will need to keep your fork up-to-date with the official repo. This is covered later in this document.}} | ||
This creates a fork under your account (for example https://pagure.io/fork/bcotton/fedora-docs/quick-docs). Now you need to "clone" | This creates a fork under your account (for example https://pagure.io/fork/bcotton/fedora-docs/quick-docs). Now you need to "clone" the upstream and forked repositories—download them to your computer. | ||
{{admon/tip|Have a dedicated directory|By default, `git clone` will clone a repository into a subdirectory named the same as the repo that exists in the directory you run the command from. In order to keep your filesystem nice and tidy, you may want to have a dedicated directory that you keep all of your docs repos in. For example: `$HOME/fedora/docs`}} | {{admon/tip|Have a dedicated directory|By default, `git clone` will clone a repository into a subdirectory named the same as the repo that exists in the directory you run the command from. In order to keep your filesystem nice and tidy, you may want to have a dedicated directory that you keep all of your docs repos in. For example: `$HOME/fedora/docs`}} | ||
# Go to the upstream Pagure repo | |||
## Click the '''Clone''' drop-down menu in Pagure | |||
## Copy the contents of the '''Git''' box | |||
## From a terminal, go to the directory you want to keep your repository in. For example `cd $HOME/fedora/docs`. You will need to create this directory if it doesn't exist (for example: `mkdir -p $HOME/fedora/docs`) | |||
## From a terminal, run `git clone <GIT URL> -o upstream`. For example `git clone https://pagure.io/fedora-docs/quick-docs/ -o upstream`. | |||
# Go to your forked Pagure repo | |||
## Click the '''Clone''' drop-down menu in Pagure | |||
## Copy the contents of the '''SSH''' box | |||
## From a terminal, go to the directory you cloned above. (For example: `cd $HOME/fedora/docs/quick-docs` | |||
# From a terminal, run `git remote add origin <SSH URL>`. For example: `git remote add origin ssh://git@pagure.io/forks/bcotton/fedora-docs/quick-docs.git` | |||
{{admon/note|Or use a graphical git tool|This document uses the terminal for git commands. However, you may also choose to use a graphical git tool. The principles of the workflow are the same.}} | |||
== Before every contribution == | == Before every contribution == |
Revision as of 21:36, 2 January 2020
Git for docs writers
I have heard from several would-be documentation contributors that they don't know how to effectively use Git to contribute to Fedora documentation. This document attempts to provide some guidance. It is intended to be opinionated to keep from overwhelming the reader.
Prerequisites
To do anything else on this page, you'll want to have the following:
- A Fedora Account System (FAS) account
- git (
dnf install git
) - The text editor of your choice
- Basic terminal experience
- (recommended) Podman (
dnf install podman
)
Before your first edit
When you first get started, you won't have commit access to the git repos for docs. You'll need to create your own copy, called a "fork". To do this,
- Go to the Pagure repo you want to fork (for example https://pagure.io/fedora-docs/quick-docs/). We will refer to this as the upstream repo from now on.
- Click the Fork button at the top.
This creates a fork under your account (for example https://pagure.io/fork/bcotton/fedora-docs/quick-docs). Now you need to "clone" the upstream and forked repositories—download them to your computer.
- Go to the upstream Pagure repo
- Click the Clone drop-down menu in Pagure
- Copy the contents of the Git box
- From a terminal, go to the directory you want to keep your repository in. For example
cd $HOME/fedora/docs
. You will need to create this directory if it doesn't exist (for example:mkdir -p $HOME/fedora/docs
) - From a terminal, run
git clone <GIT URL> -o upstream
. For examplegit clone https://pagure.io/fedora-docs/quick-docs/ -o upstream
.
- Go to your forked Pagure repo
- Click the Clone drop-down menu in Pagure
- Copy the contents of the SSH box
- From a terminal, go to the directory you cloned above. (For example:
cd $HOME/fedora/docs/quick-docs
- From a terminal, run
git remote add origin <SSH URL>
. For example:git remote add origin ssh://git@pagure.io/forks/bcotton/fedora-docs/quick-docs.git
Before every contribution
Before you start making your contributions, you want to make sure you're up-to-date with the upstream repository. This means you are making changes to the latest version.
- Ensure you're in your master branch with
git checkout master
- Get the upstream changes with
git fetch upstream
- Merge the upstream into your repo with
git merge upstream/master
Making a contribution
Now it's time to make the contribution you came here to make. You'll want to start by creating a new branch to do the work in.
git checkout -b branch_name
(where branch_name is something likeissue8-fix_typos
oradd_git_tips_for_writers
)
Now you can make whatever changes it is that you want. Fire up your favorite text editor and edit away. When you're done, it's time to commit the changes.
git add file(s) that you edited
git commit
- Edit the commit message and quit the editor. If your system uses vim as the default editor (which it probably does, unless you changed it), type
i
to enter editing mode. When you're done writing your commit message, hit the Escape key, type:wq
, and hit enter.
Finally, it's time to push your changes from your local machine to the remote server and create the pull request.
git push origin branch_name
- In your web browser, go to your forked repo (for example https://pagure.io/fork/bcotton/fedora-docs/quick-docs)
- Follow the git forge's instructions for creating a pull request (docs for Pagure and GitHub)