36
版本控制 GIT kewang

版本控制Git

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: 版本控制Git

版本控制 GITkewang

Page 2: 版本控制Git

2

git burst !!!

Page 3: 版本控制Git

3

RCS comparison

Page 4: 版本控制Git

4

server command offline software(e.g.)

Local optional cp/mv/rm optional your brain

Centralized MUST simple no SVN

Distributed optional complex optional git

Page 5: 版本控制Git

5

Git history

Page 6: 版本控制Git

6

Linux kernel file management

● 1991~2002 : Local– 大多數 Linux kernel 維護工作花在 patch 及歸檔上

● 2002~2005 : BitKeeper– 開始改為商用型 RCS : BitKeeper

● 2005~ 現在: Git– BitKeeper 與 Linux kernel 合作結束, Linus Torvalds

自行開發新的 RCS ,名為 Git

Page 7: 版本控制Git

7

from SVN migrate to Git you must know

Page 8: 版本控制Git

8

you must know

● Repositories– SVN has a central repository.– Git has a personal repository, also has an official

repository.● Revisions

– SVN revisions start at 1 and every commit increment.

– Git revisions has 40-character SHA-1(you can think of as random string).

Page 9: 版本控制Git

9

Installing......http://git-scm.com/book/en/Getting-Started-Installing-Git

Page 10: 版本控制Git

10

Creating a new repository

1.mkdir prj

2.cd prj

3.git init

Page 11: 版本控制Git

11

File Status Lifecycle

Page 12: 版本控制Git

12

Page 13: 版本控制Git

13

File Status Lifecycle

● untracked unmodified→– git add filename

● unmodified modified: modify some files→● modified staged→

– git add filename

● staged unmodified→– git commit

Page 14: 版本控制Git

14

File Status Lifecycle

● unmodified untracked→– git rm filename

● modified unmodified→– git checkout -- filename

● staged modified→– git reset HEAD filename

Page 15: 版本控制Git

15

SVN maps to Git

Page 16: 版本控制Git

16

Importing an existing project

● Git1.git init

2.git add .

3.git commit

● SVN1.svnadmin create prj_repo

2.svn import . proj_repo

Page 17: 版本控制Git

17

Check what you've done

● Git1.git diff

● SVN1.svn diff | less

Page 18: 版本控制Git

18

Reverting a file

● Git● git reset --hard HEAD filename● or● git revert HEAD filename (new commit)

● SVN1.svn revert filename

Page 19: 版本控制Git

19

Branching

● Git1.git branch new_branch old_branch

2.git checkout new_branch

● SVN1.svn copy svn://svn.example.com/old_branch svn://svn.example.com/branches/new_branch

2.svn switch svn://svn.example.com/branches/new_branch

Page 20: 版本控制Git

20

Merging

● Git● git merge branch

● SVN● svn merge -r 20:HEAD svn://svn.example.com/branches/branch

Page 21: 版本控制Git

21

and more commands...

Page 22: 版本控制Git

22

git remoting

Page 23: 版本控制Git

23

Page 24: 版本控制Git

24

github more popular !!!

Page 25: 版本控制Git

25

public repositories

private repositories

other

GitHub unlimited paid wiki, issue tracking, pull request, fork

Bitbucket unlimited free wiki, issue tracking, pull request, fork

Page 26: 版本控制Git

26

Set up Git

● Give a name– git config --global user.name "Your Name Here"

– git config --global user.email "[email protected]"

● Caching my password– git config --global credential.helper cache

Page 27: 版本控制Git

27

GitHub

Page 28: 版本控制Git

28

Step by Step

Page 29: 版本控制Git

29

Bitbucket

Page 30: 版本控制Git

30

Step by Step

Page 31: 版本控制Git

31

Downloading someone project

● git clone url prj

Page 32: 版本控制Git

32

Add a remote repository

1.git remote add origin https://example.com/hello.git

2.git push origin master

Page 33: 版本控制Git

33

Push & Pull

● Push (like svn commit)– git push

● Pull (like svn update)– git pull

Page 34: 版本控制Git

34

Links

● MY GITHUB RÉSUMÉ● Git flow開發流程● GitSvnCrashCourse● Git 教學(2):Git Branch 的操作與基本工作流程● 3.2 Git Branching - Basic Branching and Merging● 寫給大家的Git教學● Code School - Try Git

Page 35: 版本控制Git

35via http://blog.gslin.org/archives/2013/01/17/3136/

Page 36: 版本控制Git

36