Git 從入門到放棄命令大全 一

2021-10-20 17:28:24 字數 2771 閱讀 5591

對於剛學 git 的朋友來說太痛苦了,一堆命令,於是就有了這篇文章,對於常用的命令進行梳理。

git init
git init [project-name]
git clone [url]
配置檔案分為全部配置和倉庫配置,全域性配置檔案是~/.gitconfig,當前專案配置檔案是.git/config

我們平時主要修改的就是remoteuserremote配置的是遠端倉庫位址,user 配置的是你提交,推送時候用的使用者名稱和密碼,也會在 log 裡面看到。

[user]

name = 七月程式設計

email = 七月程式設計@126.com

[remote "origin"

] url =

針對倉庫的配置可以使用如下命令進行配置,如果是全域性,新增--global即可。

git config user.name 七月程式設計
git add [file1]

[file2]

...

git add [dir]
git add .
git add -p
git

rm[file1]

[file2]

...

git commit -m [message]
git commit [file1]

[file2]

... -m [message]

git commit --amend
git branch
git branch -r
git branch -a
git branch [branch-name]
git checkout -b [branch]
git branch --track [branch]

[remote-branch]

git checkout [branch-name]
git checkout -
git branch --set-upstream [branch]

[remote-branch]

git merge [branch]
git cherry-pick [commit]
git branch -d [branch-name]
git push origin --delete [branch-name]
git fetch [remote]
git remote -v
git remote add [shortname]

[url]

git pull [remote]

[branch]

git push [remote]

[branch]

git checkout [file]
git checkout .
git reset [file]
git reset --hard
git reset [commit]
git reset --hard [commit]
git revert [commit]
git stash

git stash pop

git status
git log
git log -s [keyword]
git log --follow [file]
git blame [file]
git

diff

git show [commit]
git show [commit]:[filename]
參考連線 :

Linux 命令大全 從入門到放棄

詳情見菜鳥教程 學習使用 方便查閱 1 檔案管理 catchattr chgrp chmod chown cksum cmpdiff diffstat file find gitgitview indent cutln less locate lsattr mattrib mcmdel mdir m...

git遠端從入門到放棄

git pull下來用git branch r檢視遠端分支才有資料 解決方案 指定當前工作目錄工作分支,跟遠端的倉庫,分支之間的鏈結關係。比如我們設定master對應遠端倉庫的master分支 git branch set upstream master origin master git bran...

git遠端從入門到放棄

git pull下來用git branch r檢視遠端分支才有資料 解決方案 指定當前工作目錄工作分支,跟遠端的倉庫,分支之間的鏈結關係。比如我們設定master對應遠端倉庫的master分支 git branch set upstream master origin master git bran...