git命令大雜燴

2022-03-18 11:03:14 字數 1990 閱讀 8971

檢視版本庫中的檔案:

git ls-files

新增到暫存區:

git add filesname|\foldername(迴圈遞迴) git add .(新增當前目錄下的所有檔案包括子目錄,如果新增檔案到暫存區時出現警告warning: lf will be replaced by crlf in jackydata01               git add \idea(新增指定目錄下的所有檔案)

提交到分支:

git commit -m "comment"

檢視暫存區和工作區狀態:

git status

把暫存區的修改撤銷掉:

git reset head filename

git checkout -- test.txt

修改後還沒有被放到暫存區,現在,撤銷修改就回到和版本庫一模一樣的狀態

已經新增到暫存區後,又作了修改,現在,撤銷修改就回到新增到暫存區後的狀態。

檢視log:git log 如果太長的話按方向鍵瀏覽,q退出

單行顯示:git log --pretty=oneline

回退上個版本:git reset --hard head^

回退某個版本:git reset --hard 3628164(版本id前幾位) 另外:git reflog 檢視剛剛使用的命令對應的版本

比較工作區和暫存區的區別:git diff test.txt

比較暫存區和版本庫的區別:git diff --cached test.txt

比較工作區和版本庫的區別:git diff head -- test.txt

刪除檔案:rm test.txt (刪除工作區)

刪除檔案:git rm test.txt(刪除工作區和暫存區)

刪除檔案:git rm -r --cached * (只刪除暫存區,具體的檔名或者資料夾名\folders)

git checkout之一 head基本和detached 狀態: 使用命令:git checkout master  回到master分支

分支的最新修改推送至github:git push origin master

更新本地到最新(head detached at origin/master):git pull [email protected]:hiascend/gittest.git

生成ssh key:ssh-keygen -t rsa -c "[email protected]"

git新增遠端倉庫

…or create a new repository on the command line

echo "# gittest" >> readme.md

git init

git add readme.md

git commit -m "first commit"

git remote add origin [email protected]:hiascend/gittest.git

git push -u origin master

…or push an existing repository from the command line

git remote add origin [email protected]:hiascend/gittest.git

git push -u origin master

Linux命令大雜燴

curl ifconfig.me ssh keygen t rsa scp ssh id rsa.pub root ip root ssh authorized keys 這一步需要輸入密碼 檢測登陸是否免密 ssh root 10.1.241.48 crontab e 編輯定時任務 crontab...

分頁大雜燴

文章中提到了linq,所以先介紹一下它,好讓我們有個初步認識 linq是語言級整合查詢 language integrated query linq是一種用來進行資料訪問的程式設計模型,使得.net語言可以直接支援資料查詢 linq發布於.net framework 3.5 linq體現了物件導向程...

C指標大雜燴

include int func int a,int b int main void int p int 可以看成int a int 這是乙個指標指向引數是int,返回值是int的函式。函式指標。int p int 這是乙個函式,他的引數是乙個整形,返回值是乙個指向整形的指標。include int...