Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package....

30
Get Ready for Your Experiment Xiaoli Gong [email protected] Nankai University, China

Transcript of Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package....

Page 1: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Get Ready for Your Experiment

Xiaoli Gong

[email protected]

Nankai University, China

Page 2: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Outline

Source code editor

Source code version management

Get open source code

Page 3: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Source code editor

vim

emacs

gedit

……

Page 4: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

vim

A text editor is a program that can be used to

create and modify text files. One of the most

popular editors on Linux/Unix systems (it is

also available on Windows and many other

platforms) is vi. There are many variations,

with the most popular being vim.

Page 5: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Mode in vim

Page 6: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Commands in vim

Save and quit

:w, :q

Copy and paste

p v

Insert and delete

a, i, d

https://blog.interlinked.org/tutorials/vim_tutorial.html

Page 7: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

How to use vim

Demo

More information is available online http://www.openvim.com/tutorial.html

http://vim.wikia.com/wiki/Tutorial

https://blog.interlinked.org/tutorials/vim_tutorial.html

Page 8: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Source code management

Git: for single project

Repo: for multiple projects

GBS: Huge project management

Page 9: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

GIT

Git should be pronounced: /gɪt/

Git is currently the most popular implementation

of a distributed version control system.

Git originates from the Linux kernel development

and was founded in 2005 by Linus Torvalds.

Nowadays it is used by many popular open source

projects, e.g., the Android or the Eclipse developer

teams, as well as many commercial organizations.

Page 10: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Git: Install and Configuration

Install a git package.

$ sudo apt-get install git

Configure user information of git.

This information will be used for committer

information.

$ git config --global user.name “Your name”

$ git config --global user.email email@address

ex.

$ git config --global user.name “Sun Wukong”

$ git config --global user.email [email protected]

Page 11: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

More configuration

vim ~/.gitconfig

Page 12: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Git: Key Concepts

Working directory

Source code in work

“add” command: adds

files/directories to staging area

Staging area(index)

Source code to be committed

“commit” command: makes a new

version in repository

Repository(HEAD)

Source code already committed

Files or directories are stored as

content-addressable objects

identifiable by hash value.

Working Directory

hello.c hello.h

(Local) Repository

Staging Area

Ver.1

hello.h

Ver.2

hello.c hello.h

Commit

Add

Page 13: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Version Management (1/2)

• Add a source code, ‘hello.cpp’

1. Add hello.c to staging area

1. $ git add hello.c

2. Make a new version

1. $ git commit -m “commit message”

• Add all of the source code

1. Add all of the source code

1. $ git add --all

2. Make a new version

1. $ git commit -m “commit message”

• Display staging area’s status

1. $ git status

Working Directory

hello.c hello.h

(Local) Repository

Staging Area

Ver.1

hello.h

Ver.2

hello.c hello.h

Commit

Add

Page 14: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Version Management (2/2)

Display the commit log

1. $ git log

Each commit’s hash value, author

information, date, message

commit 783c82ff64eda9f03401834de906eca77d01f691

Author: Gyeonghwan Hong <[email protected]>

Date: Mon Sep 22 10:37:44 2014 +0900

2nd version commit: hello.c is added

commit 712943bb31bf85430e1a027abe197e5b88a26110

Author: Gyeonghwan Hong <[email protected]>

Date: Thu Aug 28 12:08:17 2014 +0900

1st version commit: hello.h is added

• Return to a previous version1. git checkout <commit’s hash value>

Working Directory

hello.c hello.h

(Local) Repository

Staging Area

Ver.1

hello.h

Ver.2

hello.c hello.h

Commit

Add

– ex. git checkout 712943bb31bf85430e1a027abe197e5b88a26110

Page 15: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Local & Remote Repository (1/2)

“Commit”

Make a new version on local repository

“Push”

Upload commits in local repository to remote repository

• “Pull”– Download commits in

remote repository to local repository

Local PC

Working Directory

hello.c hello.h

(Local) Repository

Staging Area

Ver.1

hello.h

Ver.2

hello.c hello.h

Github Server (Remote)

(Remote) Repository

Ver.1

hello.h

Ver.2

hello.c hello.h

Pull

Push

Commit

Add

Page 16: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Local & Remote Repository (2/2)

• Upload to remote repository

1. $ git push <remote name> <remote branch>

– ex. $ git push origin master

Local PC

Working Directory

hello.c hello.h

(Local) Repository

Staging Area

Ver.1

hello.h

Ver.2

hello.c hello.h

Github Server (Remote)

(Remote) Repository

Ver.1

hello.h

Ver.2

hello.c hello.h

Pull

Push

Commit

Add

• Download from remote repository

1. $ git pull

Page 17: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Branch Management (1/3)

• Check the branch list of local repository

1. $ git branch --list

• Check the branch list of remote repository

1. $ git branch --remote* master

feature_x

• Move to another branch1. $ git checkout <branch name>

– ex. $ git checkout feature_x

Page 18: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Branch Management (2/3)

• Develop a new feature by making a new branch

1. Make a new branch ‘feature_x’

1. $ git branch feature_x

2. $ git checkout feature_x

2. Edit and commit source code

3. Merge ‘feature_x’ branch to original branch

1. $ git checkout master

2. $ git merge feature_x

Page 19: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Branch Management (3/3)

• Conflict

– When merging feature_y branch to master branch, ‘hello.h’ in version 2-x

and 2-y have different changes each other.

– This situation is called as ‘conflict’.

– The conflict should be resolved by ‘conflict resolution’ process.

1. $ git mergetool

• http://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-

and-Merging

Page 20: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Repo: Install and Configuration

1. Download repo.

1. $ sudo apt-get install curl

2. $ mkdir -p ~/bin

3. $ curl

"http://android.git.linaro.org/gitweb?p=tools/repo.git;a=blob_plain;f=repo;h

b=refs/heads/stable" > ~/bin/repo

4. $ chmod +x ~/bin/repo

2. Add repo’s path to the basic path list.

1. Edit ~/.bashrc

1. $ gedit ~/.bashrc

2. After adding below code to the last line, restart your shell.

PATH=~/bin:${PATH}

~/.bashrc

Page 21: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Register a Tizen developer ID

You should have an access right to review server

for accessing Tizen source code.

4. Register a Tizen developer ID

1. Go to https://developer.tizen.org/

2. You can log in Tizen review server (review.tizen.org).

Page 22: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Review Server: Configuration

1. $ gedit ~/.ssh/config

–Enter your username.

Host tizen Hostname review.tizen.org IdentityFile ~/.ssh/id_rsa User usernamePort 29418

Host review.tizen.orgHostname review.tizen.org IdentityFile ~/.ssh/id_rsa User usernamePort 29418

~/.ssh/config

Page 23: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Review Server: Configuration (Cont’d)

2. Run “ssh-keygen” on a shell.

1. $ ssh-keygen

– Press enter about every question for using default values.

– In result, id_rsa, id_rsa.pub files will be created.

» id_rsa: private key

» id_rsa.pub: public key

Page 24: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Review Server: Configuration (Cont’d)

3. After log in review.tizen.org, go to ‘settings’ menu.

4.Enter into “SSH Public Keys” menu → Press “Add Key …” button.

Page 25: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Review Server: Configuration (Cont’d)

5. Display the contents of public key file.

5. $ cat ~/.ssh/id_rsa.pub

6. Copy the displayed text to below text box.

Contents of ‘~/.ssh/id_rsa.pub’

Page 26: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Review Server: Configuration (Cont’d)

7. Test ssh server connection

1. $ ssh tizen

2. $ ssh review.tizen.org

If the connection is successful, below message will be

displayed.

Page 27: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

How to Clone Existing Repository (1/2)

1. Log in Tizen review server (review.tizen.org)

2. Enter into “Projects” → “List”

3. Find a repository that you want to clone

Be careful: Packages in Tizen 2.2 and 3.0 are managed in different

way, so multiple packages will be displayed on the result.

4. Clone the repository

1. $ git clone

ssh://[email protected]:29

418/project-name

Page 28: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

How to Clone Existing Repository (2/2)

• Tizen package repository has several branches by release

version.

5. Check branches

1. $ git branch --remote

• ex. origin/1.0_post

origin/2.0alpha

origin/HEAD -> origin/master

origin/master

origin/tizen_2.0

origin/tizen_2.1

origin/tizen_2.2

origin/tizen_2.3

6. Change branch to target release version

1. $ git checkout <target branch>

• ex. git checkout origin/tizen_2.2

Page 29: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Clone Pre-built Toolchain Packages

• Tizen source code is built by pre-built toolchains.

(Cross Compiler)

1. Clone ARM toolchain

1. $ git clone ssh://[email protected]:29418/pre-

built/toolchain-arm pre-built/toolchain-arm

2. $ cd pre-built/toolchain-arm

3. $ git checkout origin/tizen_2.2

4. $ cd -

2. Clone x86 toolchain

1. $ git clone ssh://[email protected]:29418/ pre-

built/toolchain-x86 pre-built/toolchain-x86

2. $ git pre-built/toolchain-x86

3. $ git checkout origin/tizen_2.2

4. $ cd -

Page 30: Get Ready for Your Experiment - Tizen Wiki · Git: Install and Configuration Install a git package. $ sudo apt-get install git Configure user information of git. This information

Acknowledgement

This project is partially sponsored by Tianjin Samsung

Electronics Co., Ltd.

Special thanks to SKKU Embedded Software Laboratory. This

material is based on the lecture provided by them, and the

credit goes to the original authors.