Git命令筆記

2021-10-22 22:38:22 字數 1207 閱讀 3263

#git 的三層結構

#working directory 工作區

#staging index 暫存區

#git directory(repository)版本庫

#git中檔案四種狀態

#1-> untracked 未被追蹤 2->modified 表示工作區修改了某個檔案但還未曾被新增到暫存區

#3-> staged 表示把工作區修改的檔案新增到了暫存區但是還沒有提交到版本庫

#4-> committed 表示資料被安全的儲存在本地庫中

git init #建立本地管理

git status #檢視狀態

git add filename #建立跟蹤

git commit -m 『message』 #提交

git config --list #檢視配置資訊

git log #檢視提交資訊

git reflog #檢視歷史記錄

git add . #新增所有本地檔案至暫存區

git commit --amend #撤銷上次提交,並將暫存區的檔案重新提交

git checkout --filename #切換檢出,拉取暫存區的檔案並替換工作區的檔案,注意與git checkout branchname的區別

git reset head – 拉取最近一次提交的版本庫中的filename到暫存區,該操作不影響工作區

git reset head filename #撤銷提交到暫存區的檔案

git rm filename #同時刪除暫存區和工作區檔案

git rm --cache filename #刪除暫存區中的檔案,保留工作區的檔案

git rm -f filename #強制刪除本地和暫存區檔案

git mv oldname newname #相當於mv oldname newname /git rm oldname /git add newname

git branch branchname #建立分支

git branch -d branchname #刪除分支

git checkout -b branchname #建立分支並切換至此分支

git checkout branchname #切換分支

git push http://git***xx 遠端branchname #推送

git clone http://git***xx #轉殖遠端倉庫到本地

Git命令筆記

常用配置 使用 加速git clone,這裡的1081埠在ssr客戶端選項 本地 本地埠可以設定 https.proxy git pull clone太慢的解決方法 有時候要拉的檔案太大了就會很慢,甚至拉不下來,這時候可以試試下面這個方法 git配置 取消 git config global uns...

Git 命令筆記

設定使用者資訊 git config global user.name 名字 git config global user.email 郵箱位址 設定終端配色 git config global color.diff auto git config global color.status auto ...

git命令筆記

git init 初始化乙個git倉庫,使用git init命令 git add 新增大stage git commit m 提交到本地倉庫 git config global user.name your name git config global user.email email exampl...