git克隆,更新代码库命令操作
Git 有多种使用方式。 你可以使用原生的命令行模式,也可以使用 GUI 模式,这些 GUI 软件也能提供多种功能。 在本书中,我们将使用命令行模式。
这是因为首先,只有在命令行模式下你才能执行 Git 的 所有 命令,而大多数的 GUI 软件只实现了 Git 所有功能的一个子集以降低操作难度。
如果你学会了在命令行下如何操作,那么你在操作 GUI 软件时应该也不会遇到什么困难,但是,反之则不成立。
此外,由于每个人的想法与侧重点不同,不同的人常常会安装不同的 GUI 软件,但 所有 人一定会有命令行工具。
假如你是 macOS 用户,我们希望你懂得如何使用终端(Terminal);
假如你是 Windows 用户,我们希望你懂得如何使用命令窗口(Command Prompt)或 PowerShell。
如果你尚未掌握以上技能,我们建议你先停下来快速学习一下,本书中的讲述和举例将用到这些技能。
Administrator@PC-202005152046 MINGW64 ~/Desktop (master)
$ mkdir dest.com
Administrator@PC-202005152046 MINGW64 ~/Desktop (master)
$ cd dest.com
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com (master)
$ git clone https://gitee.com/dayouke/dest.com.git --branch dev
Cloning into 'www.dest.com'...
remote: Enumerating objects: 1746, done.
remote: Counting objects: 100% (1746/1746), done.
remote: Compressing objects: 100% (1239/1239), done.
remote: Total 1746 (delta 500), reused 1573 (delta 416), pack-reused 0
Receiving objects: 100% (1746/1746), 8.48 MiB | 747.00 KiB/s, done.
Resolving deltas: 100% (500/500), done.
Updating files: 100% (1437/1437), done. Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
../../.bash_history
../../.config/
../../.node_repl_history
../../3D Objects/
../../AppData/
../../Application Data/
../../Contacts/
../../Cookies/
../
../../Documents/
../../Downloads/
../../Favorites/
../../IntelGraphicsProfiles/
../../Links/
../../Local Settings/
../../MicrosoftEdgeBackups/
../../Music/
../../My Documents/
../../NTUSER.DAT
../../NTUSER.DAT{0bcb3314-7df0-11e9-b8f1-000c2985f73e}.TM.blf
../../NTUSER.DAT{0bcb3314-7df0-11e9-b8f1-000c2985f73e}.TMContainer00000000000000000001.regtrans-ms
../../NTUSER.DAT{0bcb3314-7df0-11e9-b8f1-000c2985f73e}.TMContainer00000000000000000002.regtrans-ms
../../Pictures/
../../Recent/
../../Saved Games/
../../Searches/
../../SendTo/
../../Videos/
../../ntuser.dat.LOG1
../../ntuser.dat.LOG2
../../ntuser.ini
../../ntuser.pol
"../../\343\200\214\345\274\200\345\247\213\343\200\215\350\217\234\345\215\225/"
nothing added to commit but untracked files present (use "git add" to track)
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
../../.bash_history
../../.config/
../../.node_repl_history
../../3D Objects/
../../AppData/
../../Application Data/
../../Contacts/
../../Cookies/
../
../../Documents/
../../Downloads/
../../Favorites/
../../IntelGraphicsProfiles/
../../Links/
../../Local Settings/
../../MicrosoftEdgeBackups/
../../Music/
../../My Documents/
../../NTUSER.DAT
../../NTUSER.DAT{0bcb3314-7df0-11e9-b8f1-000c2985f73e}.TM.blf
../../NTUSER.DAT{0bcb3314-7df0-11e9-b8f1-000c2985f73e}.TMContainer00000000000000000001.regtrans-ms
../../NTUSER.DAT{0bcb3314-7df0-11e9-b8f1-000c2985f73e}.TMContainer00000000000000000002.regtrans-ms
../../Pictures/
../../Recent/
../../Saved Games/
../../Searches/
../../SendTo/
../../Videos/
../../ntuser.dat.LOG1
../../ntuser.dat.LOG2
../../ntuser.ini
../../ntuser.pol
"../../\343\200\214\345\274\200\345\247\213\343\200\215\350\217\234\345\215\225/"
nothing added to commit but untracked files present (use "git add" to track)
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
../../.bash_history
../../.config/
../../.node_repl_history
../../3D Objects/
../../AppData/
../../Application Data/
../../Contacts/
../../Cookies/
../
../../Documents/
../../Downloads/
../../Favorites/
../../IntelGraphicsProfiles/
../../Links/
../../Local Settings/
../../MicrosoftEdgeBackups/
../../Music/
../../My Documents/
../../NTUSER.DAT
../../NTUSER.DAT{0bcb3314-7df0-11e9-b8f1-000c2985f73e}.TM.blf
../../NTUSER.DAT{0bcb3314-7df0-11e9-b8f1-000c2985f73e}.TMContainer00000000000000000001.regtrans-ms
../../NTUSER.DAT{0bcb3314-7df0-11e9-b8f1-000c2985f73e}.TMContainer00000000000000000002.regtrans-ms
../../Pictures/
../../Recent/
../../Saved Games/
../../Searches/
../../SendTo/
../../Videos/
../../ntuser.dat.LOG1
../../ntuser.dat.LOG2
../../ntuser.ini
../../ntuser.pol
"../../\343\200\214\345\274\200\345\247\213\343\200\215\350\217\234\345\215\225/"
nothing added to commit but untracked files present (use "git add" to track)
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com (master)
$ git add .
warning: adding embedded git repository: Desktop/dest.com/www.dest.com
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint: git submodule add <url> Desktop/dest.com/www.dest.com
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint: git rm --cached Desktop/dest.com/www.dest.com
hint:
hint: See "git help submodule" for more information.
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com (master)
$ git add.
git: 'add.' is not a git command. See 'git --help'.
The most similar command is
add
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com (master)
$ git add .
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: www.dest.com
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: www.dest.com (modified content)
Untracked files:
(use "git add <file>..." to include in what will be committed)
../../.bash_history
../../.config/
../../.node_repl_history
../../3D Objects/
../../AppData/
../../Application Data/
../../Contacts/
../../Cookies/
../1595293957.png
../1920.png
"../2345\347\234\213\345\233\276\347\216\213.lnk"
"../360\346\236\201\351\200\237\346\265\217\350\247\210\345\231\250.lnk"
../3dcb2c1578957d173de986f6997dad81.png
"../Bootstrap \345\223\215\345\272\224\345\274\217\345\256\236\347\224\250\345\267\245\345\205\267.txt"
../Google Chrome.lnk
../Postman.lnk
../TextEditor_gr(www.greenxf.com).zip
../WPS Office.lnk
../desktop.ini
../doctor.psd
../ds.html
../new.html
../nodejs/
../s.jpg
../say.jpg
../site/
"../\345\220\216\345\217\260\346\223\215\344\275\234\346\211\213\345\206\214\357\274\210\347\256\241\347\220\206\345\221\230\357\274\211.doc"
"../\345\220\216\345\217\260\346\223\215\344\275\234\346\211\213\345\206\214\357\274\210\347\274\226\350\276\221\357\274\211.doc"
"../\345\256\275\345\270\246\350\277\236\346\216\245.lnk"
"../\345\276\256\344\277\241\345\274\200\345\217\221\350\200\205\345\267\245\345\205\267.lnk"
"../\345\277\203.png"
"../\345\277\240\344\273\225\345\225\206\345\212\241\351\200\232.lnk"
"../\346\234\252\346\240\207\351\242\230-1 \346\213\267\350\264\235.jpg"
"../\347\231\276\345\256\266\345\217\267\345\270\220\345\217\267\347\224\263\350\257\267\347\241\256\350\256\244\344\271\246.docx"
"../\347\231\276\345\272\246\345\274\200\345\217\221\350\200\205\345\267\245\345\205\267-rc.lnk"
"../\347\231\276\345\272\246\345\274\200\345\217\221\350\200\205\345\267\245\345\205\267.lnk"
"../\347\231\276\345\272\246\347\275\221\347\233\230.lnk"
"../\350\264\246\345\217\267\345\257\206\347\240\201\357\274\210\345\220\216\345\217\260\357\274\211.doc"
"../\350\277\205\351\233\267.lnk"
../../Documents/
../../Downloads/
../../Favorites/
../../IntelGraphicsProfiles/
../../Links/
../../Local Settings/
../../MicrosoftEdgeBackups/
../../Music/
../../My Documents/
../../NTUSER.DAT
../../NTUSER.DAT{0bcb3314-7df0-11e9-b8f1-000c2985f73e}.TM.blf
../../NTUSER.DAT{0bcb3314-7df0-11e9-b8f1-000c2985f73e}.TMContainer00000000000000000001.regtrans-ms
../../NTUSER.DAT{0bcb3314-7df0-11e9-b8f1-000c2985f73e}.TMContainer00000000000000000002.regtrans-ms
../../Pictures/
../../Recent/
../../Saved Games/
../../Searches/
../../SendTo/
../../Videos/
../../ntuser.dat.LOG1
../../ntuser.dat.LOG2
../../ntuser.ini
../../ntuser.pol
"../../\343\200\214\345\274\200\345\247\213\343\200\215\350\217\234\345\215\225/"
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com (master)
$ cd www.dest.com
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git status
On branch dev
Your branch is up to date with 'origin/dev'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git add .
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git commit -m "README.md"
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'Administrator@PC-202005152046.(none)')
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git status
On branch dev
Your branch is up to date with 'origin/dev'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: README.md
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git add .
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git status
On branch dev
Your branch is up to date with 'origin/dev'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: README.md
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git status
On branch dev
Your branch is up to date with 'origin/dev'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: README.md
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git add .
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git commit -m "update README.md"
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'Administrator@PC-202005152046.(none)')
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git config --global user.email "*********@qq.com"
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git config --global user.name "bobaosiren"
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git commit -m "update README.md"
[dev 6545452] update README.md
1 file changed, 2 insertions(+), 1 deletion(-)
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git add .
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git status
On branch dev
Your branch is ahead of 'origin/dev' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: README.md
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git commit -m "update READE.md"
[dev a2575ce] update READE.md
1 file changed, 2 deletions(-)
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git add .
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git commit -m "update READE.md"
On branch dev
Your branch is ahead of 'origin/dev' by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git status
On branch dev
Your branch is ahead of 'origin/dev' by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git push
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 4 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 689 bytes | 689.00 KiB/s, done.
Total 6 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/dayouke/www.dest.com.git
3c64a35..a2575ce dev -> dev
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git status
On branch dev
Your branch is up to date with 'origin/dev'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git add .
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git commit -m "update README.md"
[dev 03028c9] update README.md
1 file changed, 2 deletions(-)
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git status
On branch dev
Your branch is ahead of 'origin/dev' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git add .
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git status
On branch dev
Your branch is ahead of 'origin/dev' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git commit -m "update README.md"
On branch dev
Your branch is ahead of 'origin/dev' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 347 bytes | 347.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/dayouke/www.dest.com.git
a2575ce..03028c9 dev -> dev
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git status
On branch dev
Your branch is up to date with 'origin/dev'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git add .
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git commit -m "update README.md"
[dev 1f3df20] update README.md
1 file changed, 2 insertions(+)
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 632 bytes | 632.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/dayouke/www.dest.com.git
03028c9..1f3df20 dev -> dev
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git status
On branch dev
Your branch is up to date with 'origin/dev'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git add .
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git commit -m "update README.md"
[dev dc2605a] update README.md
1 file changed, 1 insertion(+), 3 deletions(-)
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 370 bytes | 370.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/dayouke/www.dest.com.git
1f3df20..dc2605a dev -> dev
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git status
On branch dev
Your branch is up to date with 'origin/dev'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)anges added to commit (use "git add" and/or "git commit -a")
$ git add .
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git commit -m "update README.md"
[dev c98d51d] update README.md
1 file changed, 5 insertions(+), 1 deletion(-)
Administrator@PC-202005152046 MINGW64 ~/Desktop/dest.com/www.dest.com (dev)
$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 372 bytes | 372.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/dayouke/www.dest.com.git
dc2605a..c98d51d dev -> dev
发表评论 取消回复