gitlab training with git and sourcetree

102
Gitlab Training TeerapatKhunpech VCS Technology True Information Technology 1

Upload: engineerball

Post on 13-Aug-2015

153 views

Category:

Engineering


8 download

TRANSCRIPT

Page 1: Gitlab Training with GIT and SourceTree

Gitlab Training

Teerapat Khunpech

VCS Technology

True Information Technology

1

Page 2: Gitlab Training with GIT and SourceTree

Gitlab : New Project

2

Page 3: Gitlab Training with GIT and SourceTree

Gitlab : New Project (cont.)

3

Page 4: Gitlab Training with GIT and SourceTree

Gitlab : New Project (cont.)

4

Page 5: Gitlab Training with GIT and SourceTree

TIPS

Use SSH Key

5

Page 6: Gitlab Training with GIT and SourceTree

SSH keys

SSH keys are a way to identify trusted

computers, without involving passwords. The

steps below will walk you through generating an

SSH key and adding the public key to your Gitlab

account.

6http://docstore.mik.ua/orelly/networking_2ndEd/ssh/figs/ssh_0202.gif

Page 7: Gitlab Training with GIT and SourceTree

SSH-Keygen

$ ssh-keygen –t rsa –C “[email protected]”Generate public/private rsa key pair.

Enter file in which to save the key

/home/teerapat_khu/.ssh/id_rsa: [Press enter]

Enter passphrase (empty no passphrase): [Type a passphrase]

Enter same passphrase again: [Type passphrase again]

Your identification has been saved in /home/teerapat_khu/.ssh/ida_rsa.

Your public key has been saved in /home/teerapat_khu/.ssh/ida_rsa.pub.

The key fingerprint is:

bd:10:cf:76:23:4c:c7:34:83:26:ba:f4:c3:31:c1:00 [email protected]

7

Page 8: Gitlab Training with GIT and SourceTree

SSH-Keygen

$ ssh-keygen –t rsa –C “[email protected]”Generate public/private rsa key pair.

Enter file in which to save the key

/home/teerapat_khu/.ssh/id_rsa: [Press enter]

Enter passphrase (empty no passphrase): [Type a passphrase]

Enter same passphrase again: [Type passphrase again]

Your identification has been saved in /home/teerapat_khu/.ssh/ida_rsa.

Your public key has been saved in /home/teerapat_khu/.ssh/ida_rsa.pub.

The key fingerprint is:

bd:10:cf:76:23:4c:c7:34:83:26:ba:f4:c3:31:c1:00 [email protected]

$ cat /home/teerapat_khu/.ssh/ida_rsa.pubssh-rsa

AAAAB3NzaC1yc2EAAAADAQABAAABAQDJjw9w7vbV3bQZ9kWBCBTVK2vYIMX+k6Zo6hf/MDVE2dttCdQJ87+dDdO

jRfudizsjge0nLb/pFfWtyTbZu9NGLPo/PRYD9PAPOoU6Bp9fhOCjV4ShZQQcEnZ+iIsmGAoCR08JAW/kVsu55U

8EHxuCv7Tq0L3LhUPqfbmbCO2bZP11d5kAREd4kJxA7o5SO5e2VtDJurf5COjmGXRl31AuafeXLZdtWzdSOuy5/

Lw5k+X2LnKohZYupzZ3I7O+K1x2MOuXMXgg/ZdOyyrkaMGC78s6EFhVGoTfZUU/lH8TE6v2BL0RSqbD4Ty5YZ81

+ZMezUvuyTlY7OdA6Jda/hPd [email protected]

8

Page 9: Gitlab Training with GIT and SourceTree

SSH-Keygen

$ ssh-keygen –t rsa –C “[email protected]”Generate public/private rsa key pair.

Enter file in which to save the key

/home/teerapat_khu/.ssh/id_rsa: [Press enter]

Enter passphrase (empty no passphrase): [Type a passphrase]

Enter same passphrase again: [Type passphrase again]

Your identification has been saved in /home/teerapat_khu/.ssh/ida_rsa.

Your public key has been saved in /home/teerapat_khu/.ssh/ida_rsa.pub.

The key fingerprint is:

bd:10:cf:76:23:4c:c7:34:83:26:ba:f4:c3:31:c1:00 [email protected]

$ cat /home/teerapat_khu/.ssh/ida_rsa.pubssh-rsa

AAAAB3NzaC1yc2EAAAADAQABAAABAQDJjw9w7vbV3bQZ9kWBCBTVK2vYIMX+k6Zo6hf/MDVE2dttCdQJ87+dDdO

jRfudizsjge0nLb/pFfWtyTbZu9NGLPo/PRYD9PAPOoU6Bp9fhOCjV4ShZQQcEnZ+iIsmGAoCR08JAW/kVsu55U

8EHxuCv7Tq0L3LhUPqfbmbCO2bZP11d5kAREd4kJxA7o5SO5e2VtDJurf5COjmGXRl31AuafeXLZdtWzdSOuy5/

Lw5k+X2LnKohZYupzZ3I7O+K1x2MOuXMXgg/ZdOyyrkaMGC78s6EFhVGoTfZUU/lH8TE6v2BL0RSqbD4Ty5YZ81

+ZMezUvuyTlY7OdA6Jda/hPd [email protected]

9

File

Copy this

Page 10: Gitlab Training with GIT and SourceTree

Add key to SSH Agent

$ eval `ssh-agent -s`

Agent pid 7260

10

Page 11: Gitlab Training with GIT and SourceTree

Add key to SSH Agent

$ eval `ssh-agent -s`

Agent pid 7260

$ ssh-add /home/teerapat_khu/.ssh/ida_rsa.pub

Enter passphrase for ssh-add /home/teerapat_khu/.ssh/ida_rsa.pub:

11

Page 12: Gitlab Training with GIT and SourceTree

PuTTY Key Generator

12

• On windows use Putty Key generator

Page 13: Gitlab Training with GIT and SourceTree

PuTTY Key Generator

13

• On windows use Putty Key generator

Copy this

Save to file

Page 14: Gitlab Training with GIT and SourceTree

Add SSH Key to SourceTree

14

Page 15: Gitlab Training with GIT and SourceTree

Add SSH Key to Gitlab

15

Profile Settings > SSH Keys

Page 16: Gitlab Training with GIT and SourceTree

Add SSH Key to Gitlab (cont.)

16

Profile Settings > SSH Keys > Add SSH Key

Page 17: Gitlab Training with GIT and SourceTree

SourceTree: Create New Repository

17

Page 18: Gitlab Training with GIT and SourceTree

Git: Create New Repository

$ git initInitialized empty Git repository in

/home/teerapat_khu/mywebapp/.git/

18

Page 19: Gitlab Training with GIT and SourceTree

SourceTree: Clone Gitlab Project

19

Page 20: Gitlab Training with GIT and SourceTree

Git: Clone Gitlab Project

$ git clone [email protected]:Teera36/my-

webapp.git

Cloning into 'my-webapp'...

warning: You appear to have cloned an empty repository.

Checking connectivity... done.

20

Page 21: Gitlab Training with GIT and SourceTree

SourceTree: Add Remote Repository

21

Page 22: Gitlab Training with GIT and SourceTree

SourceTree: Add Remote Repository

(cont.)

22

Page 23: Gitlab Training with GIT and SourceTree

SourceTree: Add Remote Repository

(cont.)

23

Page 24: Gitlab Training with GIT and SourceTree

SourceTree: Add Remote Repository

(cont.)

24

Page 25: Gitlab Training with GIT and SourceTree

Git: Add Remote Repository

$ git remote add gitlab-vcs \

[email protected]:Teera36/my-

webapp.git

25

Page 26: Gitlab Training with GIT and SourceTree

SourceTree: Make some change

26

Page 27: Gitlab Training with GIT and SourceTree

SourceTree: Add file to staged

27

Page 28: Gitlab Training with GIT and SourceTree

Git: Add file to staged

$ git add .

28

Page 29: Gitlab Training with GIT and SourceTree

SourceTree: Commit

29

Page 30: Gitlab Training with GIT and SourceTree

Git: Commit

$ git commit –m “First commit”[develop a75c276] First commit

18 files changed, 724 insertions(+)

create mode 100755 .bowerrc

create mode 100755 .editorconfig

create mode 100755 .gitattributes

create mode 100755 .gitignore

create mode 100755 .jshintrc

create mode 100755 .yo-rc.json

create mode 100755 Gruntfile.js

create mode 100755 app/favicon.ico

create mode 100755 app/index.html

create mode 100755 app/robots.txt

create mode 100755 app/scripts/main.js

create mode 100755 app/styles/main.css

create mode 100755 bower.json

create mode 100755 package.json

create mode 100755 test/.bowerrc

create mode 100755 test/bower.json

create mode 100755 test/index.html

create mode 100755 test/spec/test.js

30

Page 31: Gitlab Training with GIT and SourceTree

SourceTree: Log/History

31

Page 32: Gitlab Training with GIT and SourceTree

Git: Log/History

$ git logcommit a75c2764c720fd4fccab54d8ef1e8a7bb6244060

Author: teerapat_khu <[email protected]>

Date: Thu Jun 11 19:02:27 2015 +0700

First commit

32

Page 33: Gitlab Training with GIT and SourceTree

SourceTree: Push to Remote Repo

33

Page 34: Gitlab Training with GIT and SourceTree

Git: Push to Remote Repo

$ git push –u gitlab-vcs masterCounting objects: 2, done.

Writing objects: 100% (2/2), 161 bytes | 0 bytes/s, done.

Total 2 (delta 0), reused 0 (delta 0)

To [email protected]:Teera36/my-webapp.git

* [new branch] master -> master

Branch master set up to track remote branch master from gitlab-

vcs.

34

Page 35: Gitlab Training with GIT and SourceTree

SourceTree: Log/History

35

Page 36: Gitlab Training with GIT and SourceTree

Git: Log/History

$ git logcommit a75c2764c720fd4fccab54d8ef1e8a7bb6244060

Author: teerapat_khu <[email protected]>

Date: Thu Jun 11 19:02:27 2015 +0700

First commit

36

Page 37: Gitlab Training with GIT and SourceTree

SourceTree: Git Flow initial

37

Page 38: Gitlab Training with GIT and SourceTree

Git: Git Flow initial

$ git flow initNo branches exist yet. Base branches must be created now.

Branch name for production releases: [master]

Branch name for "next release" development: [develop]

How to name your supporting branch prefixes?

Feature branches? [feature/]

Release branches? [release/]

Hotfix branches? [hotfix/]

Support branches? [support/]

Version tag prefix? []

38

Page 39: Gitlab Training with GIT and SourceTree

SouceTree: Log/History

39

Page 40: Gitlab Training with GIT and SourceTree

Git: Log/History

$ git branch

* develop

master

40

Page 41: Gitlab Training with GIT and SourceTree

SourceTree: Start new feature

41

Page 42: Gitlab Training with GIT and SourceTree

SourceTree: Start new feature (cont.)

42

Page 43: Gitlab Training with GIT and SourceTree

Git: Start new feature

$ git flow feature start Create_Index_PageSwitched to a new branch 'feature/Create_Index_Page'

Summary of actions:

- A new branch 'feature/Create_Index_Page' was created, based on

'develop'

- You are now on branch 'feature/Create_Index_Page'

Now, start committing on your feature. When done, use:

git flow feature finish Create_Index_Page

43

Page 44: Gitlab Training with GIT and SourceTree

SourceTree: Log/History

44

Page 45: Gitlab Training with GIT and SourceTree

Git: Log/History

$ git branchdevelop

* feature/Create_Index_Page

master

45

Page 46: Gitlab Training with GIT and SourceTree

SourceTree: New Feature (add)

46

Page 47: Gitlab Training with GIT and SourceTree

Git: New Feature (add)

$ vi app/index.html

$ git statusOn branch feature/Create_Index_Page

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: app/index.html

no changes added to commit (use "git add" and/or "git commit -a")

47

Page 48: Gitlab Training with GIT and SourceTree

SourceTree: New Feature (add)

48

Page 49: Gitlab Training with GIT and SourceTree

Git: New Feature (add)

$ git add .

49

Page 50: Gitlab Training with GIT and SourceTree

SourceTree: New Feature (commit)

50

Page 51: Gitlab Training with GIT and SourceTree

Git: New Feature (commit)

$ git commit -m "edit for include css bower

file"[feature/Create_Index_Page 4121469] edit for include

css bower file

1 file changed, 1 insertion(+), 1 deletion(-)

51

Page 52: Gitlab Training with GIT and SourceTree

SourceTree: New Feature (log)

52

Page 53: Gitlab Training with GIT and SourceTree

Git: New Feature (log)

$ git branch

develop

* feature/Create_Index_Page

master

$ git log --graph --pretty=oneline --abbrev-commit* 4121469 edit for include css bower file

* a75c276 First commit

53

Page 54: Gitlab Training with GIT and SourceTree

SourceTree: Finish Feature

54

Page 55: Gitlab Training with GIT and SourceTree

SourceTree: Finish Feature

55

Page 56: Gitlab Training with GIT and SourceTree

Git: Finish Feature

$ git flow feature finish Create_Index_Page

Switched to branch 'develop'

Updating a75c276..4121469

Fast-forward

app/index.html | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

Deleted branch feature/Create_Index_Page (was 4121469).

Summary of actions:

- The feature branch 'feature/Create_Index_Page' was

merged into 'develop'

- Feature branch 'feature/Create_Index_Page' has been

removed

- You are now on branch 'develop'

56

Page 57: Gitlab Training with GIT and SourceTree

SourceTree: Log/History

57

Page 58: Gitlab Training with GIT and SourceTree

Git: Log/History

$ git branch

* develop

master

$ git log --graph --pretty=oneline --abbrev-commit* 4121469 edit for include css bower file

* a75c276 First commit

58

Page 59: Gitlab Training with GIT and SourceTree

SourceTree: Start New Release

59

Page 60: Gitlab Training with GIT and SourceTree

SourceTree: Start New Release

60

Page 61: Gitlab Training with GIT and SourceTree

Git: Start New Release

$ git flow release start MyWebApp-1.0-unstableSwitched to a new branch 'release/MyWebApp-1.0-unstable'

Summary of actions:- A new branch 'release/MyWebApp-1.0-unstable' was created, based on 'develop'- You are now on branch 'release/MyWebApp-1.0-unstable'

Follow-up actions:- Bump the version number now!- Start committing last-minute fixes in preparing your release- When done, run:

git flow release finish 'MyWebApp-1.0-unstable'

61

Page 62: Gitlab Training with GIT and SourceTree

Git: Log/History

$ git branch

develop

master

* release/MyWebApp-1.0-unstable

$ git log --graph --pretty=oneline --abbrev-commit* 4121469 edit for include css bower file

* a75c276 First commit

62

Page 63: Gitlab Training with GIT and SourceTree

SourceTree: Finish Release

63

Page 64: Gitlab Training with GIT and SourceTree

SourceTree: Finish Release and add Tag

64

Page 65: Gitlab Training with GIT and SourceTree

Git: Finish Release

$ git flow release finish MyWebApp-1.0-unstableSwitched to branch 'master'

Your branch is up-to-date with 'gitlab-vcs/master'.

Merge made by the 'recursive' strategy.

.bowerrc | 3 ++

.editorconfig | 21 +++++++++

.gitattributes | 1 +

Deleted branch release/MyWebApp-1.0-unstable (was

4121469).

Summary of actions:

- Latest objects have been fetched from 'origin'

- Release branch has been merged into 'master'

- The release was tagged 'MyWebApp-1.0-unstable'

- Release branch has been back-merged into 'develop'

- Release branch 'release/MyWebApp-1.0-unstable' has been

deleted

65

Page 66: Gitlab Training with GIT and SourceTree

SourceTree: Log/History

66

Page 67: Gitlab Training with GIT and SourceTree

Git: Log/History

$ git branch

develop

* master

$ git log --graph --pretty=oneline --abbrev-commit* 8811504 Merge branch 'release/MyWebApp-1.0-unstable'

|\

| * 4121469 edit for include css bower file

| |

|/

* a75c276 First commit

67

Page 68: Gitlab Training with GIT and SourceTree

Gitlab: View Branch

68

Page 69: Gitlab Training with GIT and SourceTree

Gitlab: Create New Branch

69

Page 70: Gitlab Training with GIT and SourceTree

Gitlab: Create New Branch

70

Page 71: Gitlab Training with GIT and SourceTree

SourceTree: Fetch From Remote Repo

71

Page 72: Gitlab Training with GIT and SourceTree

Git: Fetch From Remote Repo

$ git fetch gitlab-vcs

From gitlab.vcs.true.th:Teera36/my-webapp

* [new branch] develop -> gitlab-vcs/develop

72

Page 73: Gitlab Training with GIT and SourceTree

SourceTree: Push to Remote Repo

73

Page 74: Gitlab Training with GIT and SourceTree

Git: Push to Remote Repo

$ git push -u gitlab-vcs develop

Total 0 (delta 0), reused 0 (delta 0)

To [email protected]:Teera36/my-webapp.git

b28c91b..4121469 develop -> develop

Branch develop set up to track remote branch develop from

gitlab-vcs.

74

Page 75: Gitlab Training with GIT and SourceTree

Make some changes

75

Page 76: Gitlab Training with GIT and SourceTree

SourceTree: Log/History

76

Page 77: Gitlab Training with GIT and SourceTree

Git: Log/History

$ git checkout developSwitched to branch 'develop'

Your branch is up-to-date with 'gitlab-vcs/develop'.

$ vim app/index.html

$ git add .

$ git commit -m "Add \"Sign up\" Menu"[develop 13c959a] Add "Sign up" Menu

1 file changed, 1 insertion(+)

$ git log --graph --pretty=oneline --abbrev-commit* 13c959a Add "Sign up" Menu

* 4121469 edit for include css bower file

* a75c276 First commit

77

Page 78: Gitlab Training with GIT and SourceTree

SourceTree: Add Commit on Develop

78

Page 79: Gitlab Training with GIT and SourceTree

Git: Add Commit on Develop

$ vim app/index.html

$ git add .

$ git commit -m “Fix css"[develop 1c8980f] Fix css

1 file changed, 1 insertion(+)

$ git log --graph --pretty=oneline --abbrev-commit* 1c8980f Fix css

* 13c959a Add "Sign up" Menu

* 4121469 edit for include css bower file

* a75c276 First commit

79

Page 80: Gitlab Training with GIT and SourceTree

SourceTree: Start New Release

80

Page 81: Gitlab Training with GIT and SourceTree

SourceTree: Start New Release

81

Page 82: Gitlab Training with GIT and SourceTree

Git: Start New Release

$ git flow release start MyWebApp-1.1-unstableSwitched to a new branch 'release/MyWebApp-1.1-unstable'

Summary of actions:

- A new branch 'release/MyWebApp-1.1-unstable' was

created, based on 'develop'

- You are now on branch 'release/MyWebApp-1.1-unstable'

Follow-up actions:

- Bump the version number now!

- Start committing last-minute fixes in preparing your

release

- When done, run:

git flow release finish 'MyWebApp-1.1-unstable'

82

Page 83: Gitlab Training with GIT and SourceTree

SourceTree: Log/History

83

Page 84: Gitlab Training with GIT and SourceTree

Git Log/History

$ git branchdevelop

master

* release/MyWebApp-1.1-unstable

84

Page 85: Gitlab Training with GIT and SourceTree

SourceTree: Finish Release

85

Page 86: Gitlab Training with GIT and SourceTree

SourceTree: Finish Release

86

Page 87: Gitlab Training with GIT and SourceTree

Git: Finish Release

$ git flow release finish MyWebApp-1.1-unstableSwitched to branch 'master'

Your branch is up-to-date with 'gitlab-vcs/master'.

Merge made by the 'recursive' strategy.

app/index.html | 2 ++

1 file changed, 2 insertions(+)

Deleted branch release/MyWebApp-1.1-unstable (was

1c8980f).

Summary of actions:

- Latest objects have been fetched from 'origin'

- Release branch has been merged into 'master'

- The release was tagged 'MyWebApp-1.1-unstable'

- Release branch has been back-merged into 'develop'

- Release branch 'release/MyWebApp-1.1-unstable' has been

deleted

87

Page 88: Gitlab Training with GIT and SourceTree

SourceTree: Finish Release

88

Page 89: Gitlab Training with GIT and SourceTree

Git: Log/History

$ git branchdevelop

* master

$ git log --graph --pretty=oneline --abbrev-commit* e7fe2e7 Merge branch 'release/MyWebApp-1.1-unstable'

|\

| * 1c8980f Fix css

| * 13c959a Add "Sign up" Menu

* | 8811504 Merge branch 'release/MyWebApp-1.0-unstable'

|\ \

| |/

| * 4121469 edit for include css bower file

| |

|/

* a75c276 First commit

89

Page 90: Gitlab Training with GIT and SourceTree

SourceTree: Push to Remote Repo

90

Page 91: Gitlab Training with GIT and SourceTree

Git: Push to Remote Repo

$ git push -u gitlab-vcs developCounting objects: 8, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (8/8), done.

Writing objects: 100% (8/8), 701 bytes | 0 bytes/s, done.

Total 8 (delta 6), reused 0 (delta 0)

To [email protected]:Teera36/my-webapp.git

4121469..1c8980f develop -> develop

Branch develop set up to track remote branch develop from

gitlab-vcs.

91

Page 92: Gitlab Training with GIT and SourceTree

Gitlab: Merge Request

92

Page 93: Gitlab Training with GIT and SourceTree

Gitlab: Merge Request (code review)

93

Page 94: Gitlab Training with GIT and SourceTree

Gitlab: Merge Request (code review)

94

Page 95: Gitlab Training with GIT and SourceTree

Gitlab: Merge Request

95

Page 96: Gitlab Training with GIT and SourceTree

Gitlab: Merge Request

96

Page 97: Gitlab Training with GIT and SourceTree

Gitlab: Merge Request

(Accept request)

97

Page 98: Gitlab Training with GIT and SourceTree

Gitlab: Merge Request

(Accept request)

98

Page 99: Gitlab Training with GIT and SourceTree

Gitlab: History/Log

99

Page 100: Gitlab Training with GIT and SourceTree

Make some changes

100

Page 101: Gitlab Training with GIT and SourceTree

Gitlab: History/Log

101

Page 102: Gitlab Training with GIT and SourceTree

Gitlab: History/Log

102