-
更換遠程分支
- 先刪除遠程分支:
git remote rm origin - 再添加遠程分支:
git remote add origin <origin_url>
- 先刪除遠程分支:
-
新建、刪除本地分支,以及刪除遠程分支
- 新建本地分支
git branch <new_branch_name> - 刪除本地分支
git branch -d <local_branch_name> - 刪除遠程分支
git push origin --delete <remote_branch_name>
- 新建本地分支
-
獲取遠程分支
- 不重新命名
git checkout <remote_branch_name> - 重新命名
git checkout -b <local_branch_name> <remote_branch_name>
- 不重新命名
git提交,及提交到遠程分支
git push origin <remote_branch_name>:<local_branch_name>-
初始化git配置
- 配置用戶名,郵箱
git config --global user.name <user_name>
git config --global user.email <user_email> - 配置SSH
- 生成ssh-key
$ ssh-keygen -t rsa -C "idioticmadman@qq.com" Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/robert/.ssh/id_rsa): Created directory '/c/Users/robert/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/robert/.ssh/id_rsa. Your public key has been saved in /c/Users/robert/.ssh/id_rsa.pub. The key fingerprint is: SHA256:UNSglMH1hfsrjrMI3tX8/tKHE/WOoTeLtoENs9VHwok idioticmadman@qq.com The key's randomart image is: +---[RSA 2048]----+ | .o==o .. | | .oo .o. o . | | o ..E + .| | . . . o.| | S o.. ..o| | o B. o..| | . . = o+ * | | . o o....=oB o| | . o o+.+==o= | +----[SHA256]-----+
- 把公鑰添加到git服務器
- 生成ssh-key
- 配置用戶名,郵箱
-
配置多Git服務器
在.ssh文件夾下新建config文件
config.png
config文件:
# gitlab Host 192.168.10.52 HostName 192.168.10.52 PreferredAuthentications publickey IdentityFile ~/.ssh/funtsui_rsa # github Host github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa
配置submodule
添加git的子倉庫
git submodule add <repository addr> <directory>
初始化子倉庫
git submodule init
更新子倉庫
git submodule updatetag相關操作
git tag <name> -m <message> 新增tag
git tag -d <name> 刪除tag
git push origin <tag_name> 上傳tag到遠端
git push origin :refs/tags/<tag_name> 刪除遠端tag
git常用操作
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。