git 常用命令

2021-07-03 21:03:17 字數 989 閱讀 8595

git push origin :branch-name

冒號前面的空格不能少,原理是把乙個空分支push到server上,相當於刪除該分支。

git config –global alias.(命令簡寫) 命令

例如:

git config --global

alias.co commit

git config --global

alias.ci checkout

git config --global

alias.br branch

建立分支,並切換到該分支

git checkout -b branch_name
新增資料夾所有檔案

git add .
根據遠端伺服器分支,建立本地分支

git checkout -b wenlong_exec2 origin/wenlong_exec
clone遠端庫的某乙個分支

git clone -b branchname remoterep_url
例如:git clone -b template_feature

如果遠端刪除了某個分支,預設情況下,git pull 不會在拉取更新的時候,刪除對應的本地分支。這是為了防止,由於其他人操作了遠端主機,導致了git pull 不知不覺中刪除了本地分支

$ git pull -p

# 等同於下面的命令

$ git fetch --prune origin

$ git fetch -p

常用命令 Git 常用命令大全

安裝教程可參照 廖雪峰老師的安裝教程。git config 在git中,使用git config 命令來配置 git 的配置檔案,git配置級別主要有3類 1 倉庫級別 local 本地 git 倉庫級別配置檔案,作用於當前倉庫。優先順序最高 2 使用者級別 global,全域性配置檔案,作用於所有...

git 常用命令

檢視是否存在檔案需要上傳 git status git add git commit m 建立遠端倉庫 git remote add origin 116.255.146.153 ruby cd work daily project.git 更新git fetch 116.255.146.153 r...

git常用命令

詳細 1,git log p 命令來顯示每一次提交與其父節點提交內容之間快照的差異。2,為了檢視載入 staged 而並未提交 not committed 的內容差異,可以使用 git diff stage 命令 在git 1.6之前的版本中,使用 cached 適應情形 在執行git commit...