Compare commits

...
Sign in to create a new pull request.

3 commits

Author SHA1 Message Date
Eli Ridge
e2c71a806c gitwriters-draft3 2026-06-02 16:44:16 +12:00
Eli Ridge
9af4b96b6a gitwriters-draft2 2026-06-02 16:32:20 +12:00
Eli Ridge
87ce0a1a81 gitwriters-draft 2026-06-02 16:32:20 +12:00
2 changed files with 120 additions and 1 deletions

View file

@ -23,7 +23,8 @@
*** xref:contributing-docs/tools-vale-linter.adoc[How to check documentation style with Vale]
** Cheat sheets
*** xref:contributing-docs/git-for-writers.adoc[Git for writers]
** xref:contributing-docs/style-guide.adoc[The docs style guide]
** xref:contributing-docs/asciidoc-intro.adoc[AsciiDoc for Fedora]
*** xref:contributing-docs/asciidoc-markup.adoc[Markup]

View file

@ -0,0 +1,118 @@
= Git for Writers
Eli R
:revdate: 2026-05-023
This cheat sheet provides the basic commands for Fedora Docs writers to get started with git.
IMPORTANT: this cheat sheet assumes that you have previously cloned your desired repo to your computer - instructions for the instructions for this xref:forge-documentation::using_http_auth.adoc[here], and, that you have pushed your first changes to your remote fork on Forge.
//add link above to editing locally page.
//instructions on clone, add, commit, push, pull
== Basic commands
Update your local repo, main branch, so that it is in sync with the upstream repo (main branch)
----
git checkout main
git pull upstream main
----
Push your local main branch to your remote fork (main branch):
----
git push origin main
----
Update your local feature branches to be in line with your local main branch:
IMPORTANT: the following assumes your remote fork is named _origin_ in your git configuration.
1. Change to the feature branch that you want to update:
+
----
git checkout <branch-name>
----
2. If have previously stashed work, run:
+
```
git stash pop
```
3. Rebase the feature branch:
+
```
git rebase main
```
+
****
Notes: `rebase` is used instead of `merge` as rebase doesn't create any new commits, it applies commits that have been added to main to your feature branch, so it stays clean.
****
Push the updated local branch to your remote fork:
----
git push origin <branch-name> --force-with-lease
----
Update your local branch so that it is the same as your branch on your remote Fork:
****
Us this if you have made changes to your Forks branch in the Forge Web Interface:
****
----
git pull --rebase origin <name-of-branch>
----
See what files have changed when you push:
----
git diff --name-status origin/main..HEAD
----
Output:
* A added
* M modified
* D deleted
List the commits about to be pushed:
----
git log --oneline origin/main..main
----
or
----
git diff --name-only --staged
----
Push your local branch to you remote branch (of your fork):
----
git checkout <name of branch>
git push origin <name of branch>
----
Reset the current working branch to be the same as the main branch:
----
git reset --hard main
----
== Danger zone
Reset your feature branch to match your main branches state exactly, disregarding all changes to your feature branch (nukes the feature branch):
----
git checkout your-branch-name
git reset --hard main
----