$ git status
On branch main
Your branch is up to date with 'origin/main'.
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: Test.py
no changes added to commit (use "git add" and/or "git commit -a")
$ gitadd Profile/*Delete/*.txt
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: Profile/ECAPA_TDNN_GLOB_c512-ASTP-emb192-ArcMargin-LM_Delete/dummy.txt
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: Test.py
$ git commit -m"add files"[main 487222b]add files
1file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 Profile/ECAPA_TDNN_GLOB_c512-ASTP-emb192-ArcMargin-LM_Delete/dummy.txt
$ git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
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: Test.py
no changes added to commit (use "git add" and/or "git commit -a")
restore
用例:进行工作区和缓存区的恢复操作
将工作区已修改的文件恢复到修改之前
$ git status
On branch main
Your branch is up to date with 'origin/main'.
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: Test.py
no changes added to commit (use "git add" and/or "git commit -a")
$ git restore .\Test.py
$ git status
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean
将缓存区的文件恢复到工作区,工作区文件不变,相当于撤销add操作
$ gitadd .\Test.py
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: Test.py
$ git restore --staged .\Test.py
$ git status
On branch main
Your branch is up to date with 'origin/main'.
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: Test.py
no changes added to commit (use "git add" and/or "git commit -a")
gitadd .\Test.py
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: Test.py
$ gitrm--cached .\Test.py
rm'Test.py'
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: Test.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
Test.py
$ gitadd .\Test.py
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: Test.py
如果你没有commit任何东西,不要使用reset,因为这样会回退本地分支,这会导致本地分支与远程分支发生差异Your branch and 'origin/main' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours)
# 指定仓库名origin,查看该仓库的信息# 直接git remote,查看连接了哪些仓库
$ git remote show origin
* remote origin
Fetch URL: https://github.com/DEDSEC-Roger/Speaker_Recognition.git
Push URL: https://github.com/DEDSEC-Roger/Speaker_Recognition.git
HEAD branch: main
Remote branch:
main tracked
Local branch configured for'git pull':
main merges with remote main
Local ref configured for'git push':
main pushes to main (local out of date)
先去GitHub申请token,官方教程在此,拿到token后,一定要复制保存到本地
然后设置远程仓库的地址,必须先设置这个带有token的地址,才能在GitHub顺利地push
$ git remote set-url origin https://<token>@github.com/DEDSEC-Roger/Speaker_Recognition.git
$ git remote show origin
* remote origin
Fetch URL: https://<token>@github.com/DEDSEC-Roger/Speaker_Recognition.git
Push URL: https://<token>@github.com/DEDSEC-Roger/Speaker_Recognition.git
HEAD branch: main
Remote branch:
main tracked
Local branch configured for'git pull':
main merges with remote main
Local ref configured for'git push':
main pushes to main (local out of date)
pull
用例:拉取远程分支的更新,使本地分支与远程分支同步up to date
# pull的对象是某个仓库的某个分支,加上仓库名origin和分支名main更严谨一些
$ git pull origin main
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5(delta 2), reused 0(delta 0), pack-reused 0
Unpacking objects: 100% (5/5), 1.27 KiB |81.00 KiB/s, done.
From https://github.com/DEDSEC-Roger/Speaker_Recognition
b41da3b..3149ba8 main -> origin/main
Updating b41da3b..3149ba8
Fast-forward
...CAPA_TDNN_GLOB_c512-ASTP-emb192-ArcMargin-LM.onnx | Bin 24861931 ->0 bytes
Resource/origin.jpg | Bin 1852464 ->0 bytes
2 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 Model/ECAPA_TDNN_GLOB_c512-ASTP-emb192-ArcMargin-LM.onnx
delete mode 100644 Resource/origin.jpg
# 此时再查看状态,本地分支的修改还在,而且新增的文件处于Untracked状态
$ git status
On branch main
Your branch is up to date with 'origin/main'.
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: Test.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
Profile/ECAPA_TDNN_GLOB_c512-ASTP-emb192-ArcMargin-LM_Delete/
no changes added to commit (use "git add" and/or "git commit -a")
$ git remote show origin
* remote origin
Fetch URL: https://<token>@github.com/DEDSEC-Roger/Speaker_Recognition.git
Push URL: https://<token>@github.com/DEDSEC-Roger/Speaker_Recognition.git
HEAD branch: main
Remote branch:
main tracked
Local branch configured for'git pull':
main merges with remote main
Local ref configured for'git push':
main pushes to main (fast-forwardable)# push的对象是某个仓库的某个分支,加上仓库名origin和分支名main更严谨一些
$ git push origin main
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 380 bytes |380.00 KiB/s, done.
Total 4(delta 3), reused 0(delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), completed with 3local objects.
To https://github.com/DEDSEC-Roger/Speaker_Recognition.git
af33ce1..251eb2b main -> main
$ gitrm-r--cached.rm'.gitignore'rm'.vscode/launch.json'rm'Audio.py'rm'Audio/hzf_certain.wav'rm'Audio/hzf_certain_2.wav'...
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: .gitignore
deleted: .vscode/launch.json
deleted: Audio.py
deleted: Audio/hzf_certain.wav
deleted: Audio/hzf_certain_2.wav
...
$ gitadd.
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: Audio.py
deleted: Audio/hzf_certain.wav
deleted: Audio/hzf_certain_2.wav
deleted: Audio/hzf_certain_3.wav
deleted: Audio/hzf_certain_4.wav
deleted: Audio/hzf_certain_5.wav
...
$ git commit -m"completely update .gitignore"[main fa38978] completely update .gitignore
62 files changed, 1673 insertions(+), 1673 deletions(-)
delete mode 100644 Audio/hzf_certain.wav
delete mode 100644 Audio/hzf_certain_2.wav
delete mode 100644 Audio/hzf_certain_3.wav
delete mode 100644 Audio/hzf_certain_4.wav
delete mode 100644 Audio/hzf_certain_5.wav
...
$ git push origin main