Skip to content

Development and git pointers

Marc edited this page Jul 18, 2022 · 5 revisions
  • If you like (or need) to add a new feature or fix. Then create a new branch to start working on this. With this command you will create a branch add-new-feature and checks it out or switches to this new branch:
    git checkout -b add-new-feature

  • Check with this command that we are switched to the correct branch:
    git branch

  • Now you can start working on this feature:
    git status -> This will check the status of changed or added files
    git add --all -> Will stage(add) all changed (new, modified, and deleted) files

  • When you are finished with the new feature, commit this (with GPG-sign -S) to the new branch:
    git commit -S -m "Added some cool feature"

  • When you need to work on a different branch, and you are not finished to commit these changes, you can stash the changes before checking out this different branch:
    git stash -> Now the changes are stashed(saved)

    When returning to this branch you can unstash(recall) the changes with and maybe before rebase(update) from master:

    git rebase master -> Now this branch is rebase(updated) with master
    git stash pop -> Now the changes are unstashed(recall changes)

  • Now we need to merge this with master with:
    git checkout master -> Switch back to master
    git merge add-new-feature -> Merge branch add-new-feature with master
    git status -> Will show the conflicting(unmerged) files (if any occure)
    git branch -d add-new-feature -> Delete the add-new-feature if it is not needed anymore

  • When conflicts occure when merging:
    git status -> Will show the conflicting(unmerged) files

    Open these file in your editor and resolve the problems by looking for <<<<<<< HEAD etc.

    git add file.ext -> Now stage(add) the resolved file
    git status -> Check if the merge conflict is correctly resolved
    git commit -m "merged with resolved conflicts" -> Commit the merge conflicts
    git branch -d add-new-feature -> Delete the add-new-feature as it is not needed anymore