git command

21
Git Command Jason

Upload: learningtech

Post on 14-Apr-2017

213 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: git command

Git CommandJason

Page 2: git command

git work

index.html git index repository

git add index.html git commit ….

Page 3: git command

git config

Config file location: system、 global、 local

git config --global user.name "your name"

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

Page 4: git command

git init

This command creates an empty Git repository - basically a .git directory with subdirectories for objects, refs/heads, refs/tags, and template files. An initial HEAD file that references the HEAD of the master branch is also created.

Page 5: git command

git status

Displays paths that have differences between the index file and the current HEAD commit, paths that have differences between the working tree and the index file, and paths in the working tree that are not tracked by Git

Page 6: git command

git add

This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit.

git add index.html index.css

git add .

git add --update

Page 7: git command

.gitignore file

A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected;

.gitignore content

*.css!*.min.cssabc/*.txt**/foo/bara/**/b

Page 8: git command

git resetReset current HEAD to the specified state

git reset

git reset index.html

Page 9: git command

git commit

Stores the current contents of the index in a new commit along with a log message from the user describing the changes

git commit -m "commit message"

git commit --amend

Page 10: git command

git log

Shows the commit logs

git log

git log --stat

git log index.html

git log --author=’user name’

Page 11: git command

git command

git initgit configgit addgit resetgit commitgit log

git branchgit checkoutgit merge

Page 12: git command

Basic Branching and Merging ( 1 / 8 )

Page 13: git command

Basic Branching and Merging ( 2 / 8 )$ git branch iss53

$ git checkout iss53

Switched to a new branch 'iss53'

equivalent to

$ git checkout -b iss53

Switched to a new branch 'iss53'

Page 14: git command

Basic Branching and Merging ( 3 / 8 ) $ vim index.html

$ git commit -a -m 'added a new footer [issue 53]'

Page 15: git command

Basic Branching and Merging ( 4 / 8 )$ git checkout master

Switched to branch 'master'

$ git checkout -b hotfix

Switched to a new branch 'hotfix'

$ vim index.html

$ git commit -a -m 'fixed the broken email address'

Page 16: git command

Basic Branching and Merging ( 5 / 8 )$ git checkout master

$ git merge hotfix

Updating f42c576..3a0874c

Fast-forward

README | 1 -

1 file changed, 1 deletion(-)

Page 17: git command

Basic Branching and Merging ( 6 / 8 )$ git branch -d hotfix

Deleted branch hotfix (was 3a0874c).

$ git checkout iss53

Switched to branch 'iss53'

$ vim index.html

$ git commit -a -m 'finished the new footer [issue 53]'

Page 18: git command

Basic Branching and Merging ( 7 / 8 )$ git checkout master

$ git merge iss53

Auto-merging README

Merge made by the 'recursive' strategy.

README | 1 +

1 file changed, 1 insertion(+)

Page 19: git command

Basic Branching and Merging ( 8 / 8 )$ git checkout master

$ git merge iss53

Auto-merging README

Merge made by the 'recursive' strategy.

README | 1 +

1 file changed, 1 insertion(+)

Page 20: git command

Reference

https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

Page 21: git command

git command

git initgit configgit addgit resetgit commitgit log

git branchgit checkoutgit mergegit rebasegit revertgif diff