Working with git

https://gitlab.mi.hdm-stuttgart.de provides an interface creating a new Git project. This involves:

Figure 594. Steps creating a new project Slide presentation Create comment in forum
  1. Creating an empty new project itself.

  2. Adding fellow project users for participation.


Figure 595. Creating a project at MI gitlab Slide presentation Create comment in forum

Figure 596. Cloning a git project Slide presentation Create comment in forum
>git clone git@gitlab.mi.hdm-stuttgart.de:goik/vcintro.git
Cloning into 'vcintro'...
warning: You appear to have cloned an empty repository.

Figure 597. Enter project folder, add Readme.md Slide presentation Create comment in forum
>cd vcintro/
>vim Readme.md
>git add Readme.md
# Initial project description.

Will be extended when adding more assets.

Figure 598. Committing change set Slide presentation Create comment in forum
EDITOR=vim git commit Readme.md 
Adding Readme file in Markdown format
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
#
# Initial commit
#
# Changes to be committed:
#       new file:   Readme.md

Figure 599. Push to upstream repository Slide presentation Create comment in forum
>git push
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 306 bytes | 306.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To gitlab.mi.hdm-stuttgart.de:goik/vcintro.git
 * [new branch]      master -> master

Figure 600. Inserting a Maven project Slide presentation Create comment in forum
>mvn --batch-mode -e archetype:generate -Dversion=0.9 \
> -DgroupId=de.hdm_stuttgart.mi.sd1 \
> -DartifactId=first -DarchetypeGroupId=de.hdm_stuttgart.mi \
> -DarchetypeArtifactId=mi-maven-archetype-quickstart -DarchetypeVersion=1.2.1
>find first/ -type f
first/.gitignore
first/src/test/java/de/hdm_stuttgart/mi/sd1/AppTest.java
first/src/main/java/de/hdm_stuttgart/mi/sd1/App.java
first/src/main/resources/log4j2.xml
first/pom.xml

Figure 601. git status 1 Slide presentation Create comment in forum
> git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	first/

nothing added to commit but untracked files present (use "git add" to track)

Figure 602. Adding Maven files to repository Slide presentation Create comment in forum
>git add `find first/ -type f`
>git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	new file:   first/.gitignore
	new file:   first/pom.xml
	new file:   first/src/main/java/de/hdm_stuttgart/mi/sd1/App.java
	new file:   first/src/main/resources/log4j2.xml
	new file:   first/src/test/java/de/hdm_stuttgart/mi/sd1/AppTest.java

Figure 603. git status 2 Slide presentation Create comment in forum
>git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	new file:   first/.gitignore
	new file:   first/pom.xml
	new file:   first/src/main/java/de/hdm_stuttgart/mi/sd1/App.java
	new file:   first/src/main/resources/log4j2.xml
	new file:   first/src/test/java/de/hdm_stuttgart/mi/sd1/AppTest.java

Figure 604. Commit Maven project files Slide presentation Create comment in forum
EDITOR=vim git commit -a
Adding a Maven project.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Your branch is up to date with 'origin/master'.
#
# Changes to be committed:
#       new file:   first/.gitignore
#       new file:   first/pom.xml
#       new file:   first/src/main/java/de/hdm_stuttgart/mi/sd1/App.java
#       new file:   first/src/main/resources/log4j2.xml
#       new file:   first/src/test/java/de/hdm_stuttgart/mi/sd1/AppTest.java

Figure 605. git status 3 Slide presentation Create comment in forum
>git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Figure 606. Push to upstream again Slide presentation Create comment in forum
>git push
Counting objects: 22, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (22/22), 3.31 KiB | 1.10 MiB/s, done.
Total 22 (delta 0), reused 0 (delta 0)
To gitlab.mi.hdm-stuttgart.de:goik/vcintro.git
   32da2ff..4e19142  master -> master

Figure 607. Reverting changes Slide presentation Create comment in forum
>git status
...
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   Readme.md
git checkout -- Readme.md
>git status
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean

Figure 608. Pull changes from upstream Slide presentation Create comment in forum
>git pull
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
From gitlab.mi.hdm-stuttgart.de:goik/vcintro
   3751344..83bd7b9  master     -> origin/master
Updating 3751344..83bd7b9
Fast-forward
 Readme.md | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)