git命令add status commit update push

Git / 807人浏览 / 0人评论

Git克隆,更新代码库命令操作,Git 有多种使用方式。 你可以使用原生的命令行模式,也可以使用 GUI 模式,这些 GUI 软件也能提供多种功能。 在本书中,我们将使用命令行模式。这是因为首先,只有在命令行模式下你才能执行 Git 的 所有 命令,而大多数的 GUI 软件只实现了 Git 所有功能的一个子集以降低操作难度。 如果你学会了在命令行下如何操作,那么你在操作 GUI 软件时应该也不会遇到什么困难,但是,反之则不成立。

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
"../../343200214345274200345247213343200215350217234345215225/"
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
"../../343200214345274200345247213343200215350217234345215225/"
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
"../../343200214345274200345247213343200215350217234345215225/"
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
"../2345347234213345233276347216213.lnk"
"../360346236201351200237346265217350247210345231250.lnk"
../3dcb2c1578957d173de986f6997dad81.png
"../Bootstrap 345223215345272224345274217345256236347224250345267245345205267.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/ "../345220216345217260346223215344275234346211213345206214357274210347256241347220206345221230357274211.doc"
"../345220216345217260346223215344275234346211213345206214357274210347274226350276221357274211.doc"
"../345256275345270246350277236346216245.lnk"
"../345276256344277241345274200345217221350200205345267245345205267.lnk"
"../345277203.png"
"../345277240344273225345225206345212241351200232.lnk"
"../346234252346240207351242230-1 346213267350264235.jpg"
"../347231276345256266345217267345270220345217267347224263350257267347241256350256244344271246.docx"
"../347231276345272246345274200345217221350200205345267245345205267-rc.lnk"
"../347231276345272246345274200345217221350200205345267245345205267.lnk"
"../347231276345272246347275221347233230.lnk"
"../350264246345217267345257206347240201357274210345220216345217260357274211.doc"
"../350277205351233267.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
"../../343200214345274200345247213343200215350217234345215225/"
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

转载注明:

0 条评论

还没有人发表评论

发表评论 取消回复

记住我的信息,方便下次评论
有人回复时邮件通知我