GIT 基本命令

2021-08-21 09:56:48 字數 1049 閱讀 2324

git基本命令

git clone url 從遠端倉庫獲取**

git push 把**更新到遠端倉庫

git pull 從遠端倉庫拉取**,並合併到當前分支

本地倉庫操作

git init 初始化乙個本地倉庫,之前新建乙個檔案(.gitignore)忽略不需要匹配的檔案。

如果初始化成功後已經存在的檔案已經被匹配到本地倉庫中了。window下,必須有檔名。

使用gitbash-> touch .gitignore新建檔案。

git add . / 'login.html' 將所有檔案或某個檔案修改狀態為已跟蹤

git reset head filename 取消暫存狀態,從跟蹤到修改。

git checkout -- filename 取消修改,跟本地倉庫同步

git status 檢視倉庫中檔案的狀態

git commit -m "msg" 提交到本地倉庫,資訊為msg(必須填寫)

git rm 'file.name' 刪除某個檔案,未提交

git log 檢視提交記錄

git tag -a tagname -m 'msg' 給某個重要節點打標籤,可用於記錄版本

git remote 檢視已經配置的遠端伺服器資訊

git remote batchname newbatchname 更新分支名稱

git config --global alias.ci commit 給命令起別名。用ci代替commit

touch filename 新建檔名 //window下新建.gitignore.因為window不允許檔名為空

window命令列

mkdir dirname //新建目錄

rmdir dirname //刪除目錄

type nul > filename //新建檔案 //可以新建檔名為空的檔案.gitignore

del filename // 刪除檔案

git 基本命令

man git man git commit man git pull man git merge git config global user.name yourname git config global user.email yourname example.com cd home git m...

Git 基本命令

git config global user.name xx git config global user.email x com 1.建立專案資料夾 mkdir myproject 2.進入專案資料夾 cd myproject 3.初始化專案 git init 4.建立 readme.md tou...

Git 基本命令

說明 以下所有操作命令 均在 git bash 下執行,即命令為linux風格 檔案 以 txt 為例 其中,建立某乙個倉庫,在某一具體路徑下 執行 git init即可 幫助命令 git help 建立 respository git init 刪除 respository rm rf git 建...