Skip to content

How to make a merge request (pull request)

Kreyren edited this page Nov 23, 2019 · 3 revisions

This is stub documentation, contributions are welcomed.


TL;DR

  • Fork repository
  • Clone your forked repository (git clone path/to/forked/repo)
  • Make a new branch (git checkout -b name)
  • Make your changes in the file
  • Commit the changes (git commit -a)
  • Push the changes (git push remote branch)
  • Make a merge/pull request by natigating on your repository and pressing "Pull Request"

Basics

  • You have to change directory to your git directory for it to accept git commands unless you are using git worktree=path/to/git/dir commands
  • git is using remotes to manipulate commits where origin is default remote
  • Changes on remotes are differenciated in branches where master is default branch

1) Fork repository

Forking is done on github gui image

Which is going "copy" repository in your profile or target organization.

2) Cloning repository

Once you forked repository to which you want to contribute you need to clone it to have write access and stage changes.

# 'Download' repository in your system
git clone url path/to/dir

We recommend using /usr/src/name which is respecting FHS 3.0 (https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s12.html)


Alternatively you can make a new directory in path/to/dir and invoke git init which is going to convert said directory into a git directory, add a new remote by invoking git remote add origin url and pulling from said remote by invoking git pull origin master (Origin is default remote set by git)

Remotes are remote repositories from which git is able to fetch commits

sidenote: You may need to invoke git fetch to fetch all references

3) Make a new branch

To differenciate the changes from your master (main branch by default) we require that you make a new branch tracking changes from master

# Make a new branch tracking from current branch
git checkout -b name

4) Make your changes

You can now make your changes to the forked repository which are going to be tracked by git later

5) Commit the changes

Git is using commits to index the file changes

# Commit your changes
git commit -a
# Commit without openning the text editor (not recommended unless you know what are you doing)
git commit -m 'msg'

Note that if you created a new file you may need to invoke git add path/to/new/file/in/git/dir for git to track it.

Please review the changes that you are making in the commit

6) Push the changes

For changes to be available on your remote repository like github you need to push them.

# Push changes on remote repository
git push remote branch

Where remote is by default origin and branch is your branch that you just created.

7) Make a Merge request

(or as github calls it pull request which is just wrong)

Open up gitub and use a GUI to make a merge request: image

Make sure that you are merging from correct repository and branch to correct repository and branch. image

Please review commits before merging we are ideally expecting one commit per change image

Ideally make a description that is sensible to others to know what are you changing and why