git簡介html
git生態python
git安裝git
git配置github
四個區域緩存
四種狀態curl
經常使用命令分佈式
[root@localhost test]# echo "pay" > pay.html [root@localhost test]# echo "center" > news.html [root@localhost test]# git add pay.html news.html [root@localhost test]# git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: news.html new file: pay.html [root@localhost test]# git rm --cached pay.html rm 'pay.html' [root@localhost test]# git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: news.html Untracked files: (use "git add <file>..." to include in what will be committed) pay.html
分支管理gitlab
分支命令fetch
git高級this
git checkout命令
[root@localhost test]# echo "222" >> index.html [root@localhost test]# git status On branch master 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: index.html no changes added to commit (use "git add" and/or "git commit -a") [root@localhost test]# git checkout -- index.html [root@localhost test]# git status On branch master nothing to commit, working directory clean [root@localhost test]# cat index.html joker
git reset命令
意義在於,區域用不用保留
工做目錄的回滾
git checkout -- file.ext 撤銷對文件的修改
暫存區的回滾
git rm --cached 撤回緩存區的文件
[root@localhost test]# echo 333 >> index.html [root@localhost test]# echo 333 >> news.html [root@localhost test]# git add news.html [root@localhost test]# git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: news.html 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: index.html [root@localhost test]# git log commit c203cce4db08d7787c48cf6fe7f5edda50b7c906 Merge: fe7194c 885b5d3 Author: joker <joker@126.com> Date: Mon Dec 17 22:24:56 2018 -0500 Merge branch 'about' commit 885b5d3dedfc59346535588685f4f41464f85594 Author: joker <joker@126.com> Date: Mon Dec 17 22:13:14 2018 -0500 about commit fe7194ca1d692cf55316481b2d34b3de2c354b9e Author: joker <joker@126.com> Date: Mon Dec 17 22:05:06 2018 -0500 pay commit c415b7b4c9d5c7dc6abf00fedca3a0d1307e524f Author: joker <joker@126.com> Date: Mon Dec 17 10:06:55 2018 -0500 news commit 8c8152d501f7eb25a78c4d576a9ff2ce834ae65f Author: joker <joker@126.com> Date: Mon Dec 17 10:01:32 2018 -0500 first commit [root@localhost test]# git reset --hard c415b7b(回滾到哪一次提交) HEAD is now at c415b7b news [root@localhost test]# git status On branch master nothing to commit, working directory clean [root@localhost test]# git log commit c415b7b4c9d5c7dc6abf00fedca3a0d1307e524f Author: joker <joker@126.com> Date: Mon Dec 17 10:06:55 2018 -0500 news commit 8c8152d501f7eb25a78c4d576a9ff2ce834ae65f Author: joker <joker@126.com> Date: Mon Dec 17 10:01:32 2018 -0500 first commit
文件層操做
git reflog
[root@localhost test]# git reflog c415b7b HEAD@{0}: reset: moving to c415b7b4c9d5c7dc6abf00fedca3a0d1307e524f 885b5d3 HEAD@{1}: merge res: Fast-forward c415b7b HEAD@{2}: checkout: moving from res to master 885b5d3 HEAD@{3}: checkout: moving from 885b5d3dedfc59346535588685f4f41464f85594 to res 885b5d3 HEAD@{4}: checkout: moving from master to 885b5d3 c415b7b HEAD@{5}: checkout: moving from reset to master c415b7b HEAD@{6}: checkout: moving from master to reset c415b7b HEAD@{7}: checkout: moving from 885b5d3dedfc59346535588685f4f41464f85594 to master 885b5d3 HEAD@{8}: checkout: moving from master to 885b5d3 c415b7b HEAD@{9}: reset: moving to c415b7b c203cce HEAD@{10}: merge about: Merge made by the 'recursive' strategy. fe7194c HEAD@{11}: checkout: moving from about to master 885b5d3 HEAD@{12}: checkout: moving from master to about fe7194c HEAD@{13}: checkout: moving from about to master 885b5d3 HEAD@{14}: commit: about c415b7b HEAD@{15}: checkout: moving from master to about fe7194c HEAD@{16}: commit: pay c415b7b HEAD@{17}: checkout: moving from about to master c415b7b HEAD@{18}: checkout: moving from master to about c415b7b HEAD@{19}: commit: news 8c8152d HEAD@{20}: commit (initial): first commit [root@localhost test]# git checkout 885b5d3 Note: checking out '885b5d3'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b <new-branch-name> HEAD is now at 885b5d3... about [root@localhost test]# git status HEAD detached at 885b5d3 nothing to commit, working directory clean [root@localhost test]# git branch rese [root@localhost test]# git checkout rese Switched to branch 'rese' [root@localhost test]# git log commit 885b5d3dedfc59346535588685f4f41464f85594 Author: joker <joker@126.com> Date: Mon Dec 17 22:13:14 2018 -0500 about commit c415b7b4c9d5c7dc6abf00fedca3a0d1307e524f Author: joker <joker@126.com> Date: Mon Dec 17 10:06:55 2018 -0500 news commit 8c8152d501f7eb25a78c4d576a9ff2ce834ae65f Author: joker <joker@126.com> Date: Mon Dec 17 10:01:32 2018 -0500 first commit [root@localhost test]# git checkout master Switched to branch 'master' [root@localhost test]# git log commit c415b7b4c9d5c7dc6abf00fedca3a0d1307e524f Author: joker <joker@126.com> Date: Mon Dec 17 10:06:55 2018 -0500 news commit 8c8152d501f7eb25a78c4d576a9ff2ce834ae65f Author: joker <joker@126.com> Date: Mon Dec 17 10:01:32 2018 -0500 first commit [root@localhost test]# git merge rese Updating c415b7b..885b5d3 Fast-forward about.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 about.html [root@localhost test]# git log commit 885b5d3dedfc59346535588685f4f41464f85594 Author: joker <joker@126.com> Date: Mon Dec 17 22:13:14 2018 -0500 about commit c415b7b4c9d5c7dc6abf00fedca3a0d1307e524f Author: joker <joker@126.com> Date: Mon Dec 17 10:06:55 2018 -0500 news commit 8c8152d501f7eb25a78c4d576a9ff2ce834ae65f Author: joker <joker@126.com> Date: Mon Dec 17 10:01:32 2018 -0500 first commit
遠程倉庫
遠程命令
標籤管理