Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
themeEclipse
firstline1
titlepull master
linenumberstrue
git rebase upstream/master # rebase-method (recommended, because commit-graph will be cleaner)
or
git pull upstream master   # merge-method '--force' (if you want to dismiss local changes)

Checkout new branch

If there is a new incoming ticket you need to checkout an extra branch for this job.

...

  • git branch printing all existing branches.
  • git branch <name> creating a new branch.
  • git checkout -b <branchname> will create a new branch and switch directly to it.

Commit changes

Show/add current changes

Code Block
languagebash
themeEclipse
firstline1
titleshow changes
linenumberstrue
git status

...

  • RED colored lines are changes which are untracked/unstashed.
  • GREEN colored lines are changes which are marked for the next commit.

Add/remove changes

Code Block
languagebash
themeEclipse
firstline1
titleadd/remove current changes
linenumberstrue
git add .   # Adding ALL changes
git add /src/java/....  # Add only this file

git checkout . # remove all uncomitted changes
git checkout /src/... # remove changes at this file or untrack it again.

Squash commits

After finishing the current ticket all new commits should be squashed together.

...

Previous commit-massages can be changed if you want to.
So commits like "TEMP" or "ZWISCHENSTAND" can be deleted/changed.

Update and rebase ticket-branch

After squashing your commit into only 1 you need to update and rebase it against the current UPSTREAM/MASTER (or HEAD).
This will keep the graph clean and there will be no confusing problems later.

...

Code Block
languagebash
themeEclipse
firstline1
titleShow only files with conflicts
linenumberstrue
git diff --name-only --diff-filter=U  # show only files with conflicts

Create a pull-request

  • Current branch needs to be pushed to your remote repo. git push origin <branchname>
  • Click "create pullrequest" 

If you want to update a pull-request you just need to push your branch again.
Maybe  push --force ... needs to be used, because squashed commits are not recognized as a newer version.

Integrate a Pull-Request

Workflow for integrating a pull-request.

  • Checkout to your local master-branch
  • Get the latest update of the remote-repo
    • pull from upstream master (merge-method)
    • rebase to upstream master (rebase-method, recommended) 
  • Download the branch which is marked for pull-request

    Code Block
    languagebash
    themeEclipse
    titledownload pull-request branch
    git fetch upstream pull/<#PULL_REQUEST_ID>/head:<BRANCHNAME>


  • Checkout to the new downloaded branch

  • Rebase against upstream/master
    • No conflicts - go on
    • Conflicts → REJECT and let the branch-owner update the pull request to new version.
  • Build all projects and test code and quality
    • REJECT if quality low, subjects missing, tests not complete, ...
  • ONLY MERGE-METHOD
    • Checkout back to your master


    • Merge the branch into master (rebase again optional)

      Code Block
      languagebash
      themeEclipse
      titlemerge an other branch into current one
      git merge <BRANCHNAME>


  • push to remote (upstream) master and optional to your own remote
  • DONE

Log - Graph (Commithistory)

Code Block
languagebash
themeEclipse
firstline1
titleview commit-graph
linenumberstrue
git log  # showing logs with meta-data, escape with 'q'
git log --graph  # showing logs with commit-graph
git log --one-line  # only first line of commit-messages without any other meta-data - very short overview
git log --graph --one-line  # showing commit-graph with 1 lone commit-messsage

# Add it as short alias
git config --global alias.lg 'log --graph --one-line' # without GIT!
git lg  # showing commit-graph with 1 lone commit-message

This command can be used to see the current git-graph, which should be only 1 line after merging.


Transfer Commit from branch A to B


Maybe your current branch crashed or you can´t fix the merge-conflicts with the current upstream/master, then you can pick a commit from another branch (A)
and copy it ontop of another one (B).
This process called and can be done by cherry-picking.

...