Skip to content

git Reference

All the nitty gritty for a reference doc without the rambling of a blog post 😉

Be Aware of 🐲 git has em' - git command cannot perform PRs you will need to use tools like gh, berg, tea - berg doesn't seem to support creating PRs just editing them? - tea works across gitea, forgejo, and codeberg - Use tea for Codeberg so you can easily perform PRs since they are pivotal - tea is great since you can use Nix and direnv to create isolated tea configs and support using this across tons of git instances, one command base many platforms❤️‍🔥 - You CAN'T sign merge requests if you don't control the git server

Step 1: Prepare your feature branch

You can either fork a remote repo and create your feature branch, or if you have an existing git repo just checkout a new branch and you are off to the races.

Switch to your feature branch

git checkout feature/new-feature

Ensure your branch is up-to-date with the latest changes from main

git pull origin main --rebase

Commit any pending changes

git add .
git commit -m "Commit message"

Step 2: Push your feature branch to remote

git push origin feature/new-feature

Step 3: Create a pull request (using Git command line)

Unfortunately, Git command line doesn't directly support creating pull requests. However, you can use the git request-pull command to generate a pull request message, then manually create the PR on the web interface:

git request-pull origin/main feature/new-feature

This command generates a text output with the pull request information. Copy this output and create a new pull request on the web interface. Or use the tea tool.

OR

Use the platform tooling to finish the pull and merge requests from the command line.

tea pull create --title "PR title" --description "PR description" --head feature/new-feature --base main

  • tea pull create - Create a new pull request
  • tea pull list - List pull requests
  • tea pull view - View a pull request
  • tea pull update - Update a pull request
  • tea pull delete - Delete a pull request

Step 4: Review and merge the pull request

Signed merge requests does not work on hosted Gitea, Codeberg, Forgejo instances. In order to make it work you need to be in control of the server and can define a global signing key. See discussion here about the issue.

Switch to main branch

git checkout main

tea pull review PR_ID

Merge the feature branch into main

Since we have branch protection enabled on main we use pull merge which creates a merge commit to main rather than a pull request✨ You comply with no pull request on main.

tea pull merge --title "testing merge cli" --message "testing description" PR_ID

If no branch protection was on you could merge and push normally

git merge feature/new-feature

Push the updated main branch to remote

git push origin main

Delete the feature branch

git branch -d feature/new-feature
git push origin --delete feature/new-feature

Short Hand

git checkout feature/new-feature
git pull origin main --rebase
git add .
git commit -m "Commit message"
git push origin feature/new-feature
tea pull create --title "PR title" --description "PR description" --head feature/new-feature --base main
git checkout main
tea pull review PR_ID
tea pull merge --title "testing merge cli" --message "testing description" PR_ID