SCM - Git demo

IT1901 Fall 2020 - 4th lecture

Git demo

Installing and setting up git

Typical sequence (share project)

  • starting a project and sharing it on Gitlab for team collaboration

    • git init

    • git status

  • git add …​

  • git commit …​

  • git remote …​

  • git push

Commit messages

Commit messages (seriously)

  • Separate subject from body with a blank line

  • Limit the subject line to 50 characters

  • Capitalize the subject line

  • Do not end the subject line with a period

  • Use the imperative mood in the subject line

  • Wrap the body at 72 characters

  • Use the body to explain what and why vs. how

Typical sequence (simple collaboration)

  • working with a shared project

    • git clone

    • git pull

  • git status

  • git add …​

  • git commit …​

  • git push

Conflicts (1)

  • when same files (lines) are changed by different devs

  • automatic merge is not possible

  • we need to solve that to be able to push our changes

Conflicts (2) - Setup

  • git config merge.tool vimdiff

  • git config merge.conflictstyle diff3

  • git config mergetool.prompt false

Conflicts (3) - Solving

  • git mergetool

  • :wqa save and exit from vi

  • git commit -m "message"

  • git clean remove file (might remove other untracked files)

Typical sequence (with branching)

  • working with branches

    • git pull

    • git checkout -b <branch_name>

    • git status + git add …​ + git commit …​

    • git checkout master

    • git merge <branch_name>

Norwegian University of Science and Technology