git command
TRANSCRIPT
![Page 1: git command](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/1.jpg)
Git CommandJason
![Page 2: git command](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/2.jpg)
git work
index.html git index repository
git add index.html git commit ….
![Page 3: git command](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/3.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/4.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/5.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/6.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/7.jpg)
.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](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/8.jpg)
git resetReset current HEAD to the specified state
git reset
git reset index.html
![Page 9: git command](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/9.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/10.jpg)
git log
Shows the commit logs
git log
git log --stat
git log index.html
git log --author=’user name’
![Page 11: git command](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/11.jpg)
git command
git initgit configgit addgit resetgit commitgit log
git branchgit checkoutgit merge
![Page 12: git command](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/12.jpg)
Basic Branching and Merging ( 1 / 8 )
![Page 13: git command](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/13.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/14.jpg)
Basic Branching and Merging ( 3 / 8 ) $ vim index.html
$ git commit -a -m 'added a new footer [issue 53]'
![Page 15: git command](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/15.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/16.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/17.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/18.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/19.jpg)
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](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/20.jpg)
Reference
https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
![Page 21: git command](https://reader035.vdocuments.site/reader035/viewer/2022070601/5889b8cf1a28aba54d8b6b21/html5/thumbnails/21.jpg)
git command
git initgit configgit addgit resetgit commitgit log
git branchgit checkoutgit mergegit rebasegit revertgif diff