Git命令
git --help
git [command] --help
git init
git add .
命令实例:
root@DESKTOP-33IBDMI:/mnt/e/git
root@DESKTOP-33IBDMI:/mnt/e/git
1.txt
root@DESKTOP-33IBDMI:/mnt/e/git
git status
命令实例:
root@DESKTOP-33IBDMI:/mnt/e/git
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: 1.txt
git commit -m "此次提交的描述" #把所修改的文件提交到本地仓库
注:使用-m选项说写一段概要说明,所写得内容不要随便写,最好是说明commit后增加或修改了哪些功能。
命令实例:
root@DESKTOP-33IBDMI:/mnt/e/git# git commit -m "add 1.txt"
[master c42772f] add 1.txt
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 1.txt
git rm --cache [文件名]
命令实例:
root@DESKTOP-33IBDMI:/mnt/e/git
root@DESKTOP-33IBDMI:/mnt/e/git
root@DESKTOP-33IBDMI:/mnt/e/git
rm '2.txt'
root@DESKTOP-33IBDMI:/mnt/e/git
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
2.txt
nothing added to commit but untracked files present (use "git add" to track)
git rm [文件名]
rm [文件名]
命令实例:
root@DESKTOP-33IBDMI:/mnt/e/git
rm '1.txt'
root@DESKTOP-33IBDMI:/mnt/e/git
[master 1bef8f7] rm 1.txt
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 1.txt
root@DESKTOP-33IBDMI:/mnt/e/git
root@DESKTOP-33IBDMI:/mnt/e/git
On branch master
Changes not staged for commit:
deleted: 2.txt
no changes added to commit
root@DESKTOP-33IBDMI:/mnt/e/git
root@DESKTOP-33IBDMI:/mnt/e/git
[master 9a40f23] dele 2.txt
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 2.txt
git checkout [文件名]
git checkout [分支名] [文件名]
命令实例:
root@DESKTOP-33IBDMI:/mnt/e/git
root@DESKTOP-33IBDMI:/mnt/e/git
11.txt
root@DESKTOP-33IBDMI:/mnt/e/git
root@DESKTOP-33IBDMI:/mnt/e/git
root@DESKTOP-33IBDMI:/mnt/e/git
[master ef5b5ee] add 11.txt
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 11.txt
root@DESKTOP-33IBDMI:/mnt/e/git
root@DESKTOP-33IBDMI:/mnt/e/git
1111
root@DESKTOP-33IBDMI:/mnt/e/git
root@DESKTOP-33IBDMI:/mnt/e/git
root@DESKTOP-33IBDMI:/mnt/e/git