git常用指令

2021-07-25 05:34:43 字數 1948 閱讀 6084

git 常用命令

git init here --建立本地倉庫(repository),將會在資料夾下建立乙個 .git 資料夾,.git 資料夾裡儲存了所有的版本資訊、標記等內容

git remote add origin [email protected]:winter1991/helloworld.git

--把本地倉庫和遠端倉庫關聯起來。如果不執行這個命令的話,每次 push 的時候都需要指定遠端伺服器的位址

git add --從本地倉庫增刪,結果將會儲存到本機的快取裡面

git rm

git commit -m "

注釋" --提交,把本機快取中的內容提交到本機的 head 裡面

git pull origin master --從遠端伺服器 pull 新的改動

git status --檢視狀態

git add -a --提交全部修改

1. git 配置:

git config --global user.name "

***" --配置使用者名稱,上傳本地 repository 到伺服器上的時候,在 github 上會顯示這裡配置的上傳者資訊

git config --global user.email "

***" --配置郵箱

git config --list 檢視配置列表

配置 sshkey : 上傳**時使用這個 sshkey 來確認是否有上傳許可權

1. 建立本地 ssh : ssh-keygen -t rsa -c "

github 的註冊郵箱"2

. 在 github 中新增這個 sshkey :

複製 c:\documents and settings\administrator\.ssh\id_rsa.pub 檔案中的內容;

登入 github --> account setting --> ssh-key --> add ssh-key -->貼上id_rsa.pub中的內容;

3. 驗證: ssh -t [email protected]

出現 hi ***! you'

ve successfully authenticated, but github does not provide shell access. 說明配置成功,可以連線上 github

2. 建立倉庫 repository :

git init here --建立本地倉庫

git remote add origin [email protected]:使用者名稱/倉庫名.git

--把本地倉庫和遠端倉庫關聯起來, 如果不執行這個命令的話,每次 push 的時候都需要指定遠端伺服器的位址

3git pull origin master

4. 提交本地修改到遠端倉庫中:

git add

git add -a --將改動新增到本地倉庫中

git rm *** --從本地倉庫中刪除指定檔案

git rm -r *** --從本地倉庫中刪除指定資料夾

git commit -m "

注釋" --把本機快取中的內容提交到本機的 head 裡面

git push origin master --把本地的 commit push 到遠端倉庫中

5. 使用 .gitignore 檔案忽略指定的內容:

1. 在本地倉庫根目錄建立 .gitignore 檔案。win7 下不能直接建立,可以建立 "

.gitignore.

"檔案,後面的標點自動被忽略;

2. 過濾檔案和資料夾: [tt]emp/ 過濾 temp\temp 資料夾; *.suo 過濾 .suo 檔案;

3. 不過濾檔案和資料夾: !*.c

Git 常用指令

首先需要建立乙個repo,這是cd到資料夾底下,然後init。git init 在檔案系統裡面的檔案如果不新增到git的repo裡面,不會自動被git辨識,需要手動新增,這也是初始化repo是必須要做的事。git add documentation txt git add git sh 刪除檔案,分...

git常用指令

git 常用命令 git init here 建立本地倉庫 repository 將會在資料夾下建立乙個 git 資料夾,git 資料夾裡儲存了所有的版本資訊 標記等內容 git remote add origin git github.com winter1991 helloworld.git 把...

git常用指令

git config global user.name robbin git config global user.email fankai gmail.com git config global color.ui true git config global alias.co checkout g...