wiki.ipfire.org

The community-maintained documentation platform of IPFire

User Tools

Site Tools


devel:git:start

Git Guide

Git is the central place of the project. Inside this repository we store all changes of the Source Code.

Before you are able to make your own changes to the source code you need to setup Git:

Using git - Dealing with branches

It is strongly recommended to use branches to keep a clean and stable master repository.

To get the latest changes type:

git pull origin master

NOTE: This will download the latest changes from the IPFire server and apply them to the current(!) branch.

To get remote branches add them and use:

git fetch name

To list all available branches use:

git branch or git branch -la

To list all remote branches of a user type:

git remote show name

To create a new branch type:

git checkout -b branchname

NOTE: It is also possible to create a local branch and track them to an other or remote branch type:

git checkout -b branchname -t name/branch

To switch between branches type:

git checkout an-other-branch

To remove existing local branches type:

git branch -d branchname

To remove existing remote branches type:

git push username :branchname

To rename a branch use:

git branch mv old name new name

To merge branches together type:

git merge brachname

NOTE: This will merge the content of the choosen branch into the current(!) branch.

To autoremove local branches if the remote ones has been deleted use:

git remote prune origin --dry-run

NOTE: The add of “–dry-run” will show you the branches which will be deleted, if you don't use it git immediately will start to delete the branches.

Using git - Dealing with files

Use git to add a new file:

git add path/to/file.nm

NOTE: It's also possible to add more files or folders at the same time.

To rename or move a file use:

git mv path/to/old/file.nm path/to/new/file.nm or git mv oldfile.nm newfile.nm

To delete a file type:

git del path/to/file.nm

Using git - Share changes

To share your changes with the community or the developers you have to commit them. A commit is a permanent save of all changes. So the should be checked carefully.

NOTE: Keep in mind to get the latest changes from upstream before commit anything.

To do this use:

git commit file/to/commit or git commit file/to/commit an/other/file

IMPORTANT: Use commit messages like: “pkg name: Summary of your changes.”

If you have an development account you can push your commits to the git server. If you haven't an own account you have to create a patchfile.

Edit a previous not pushed commit

To do this type:

 git commit --amend

Creation of a patchfile

To do this type:

 git format-patch origin master --stdout > patchfile.patch
 

To create a patchfile from a commit use:

 git format-patch -1 <sha> - where <sha> is the id from the commit

Apply a patchfile

It is recommended do check received patchfiles before applying them:

git apply --stat patchfile.patch # To show the header
git apply --check patchfile.patch # To check the patch

Finally assume the changes:

git apply patchfile.patch

Push commits

To push your changes type:

git push name branch

Important rules:

  1. Never commit anything to your master. This branch should always be clean and untouched.
  2. Create an own branch for every feature or bug you aim to develop or fix.
  3. Never send a push request when a feature is not stable or tested very well.
  4. To get feedback from other developers share your branch, receive reviews, patches, etc.
devel/git/start.txt · Last modified: 2016/01/29 02:11 by MichaelTremer