# git [官方下载](https://git-scm.com/) ## git常用命令 ```sh # 从git上拉项目 # 首先创建好本地目录 git init # gogs是命名,一般用origin git remote add remoteName git-address git pull remoteName branchName # 修改git地址 git remote set-url remoteName newBranchName # 全局设置 # 不设置全局的话,在每一个仓库第一次提交时都需要先设置用户名和邮箱 git config --global user.name "yourName" git config --global user.email "yourEmail" # 设置自动保存帐号密码 git config --global credential.helper store # 同步tags到远端 git push origin --tags # 生成公钥和私钥 ssh-keygen -t rsa -C "yourEmail" # ssh测试 ssh -t git@仓库地址 # 分支改名 git branch -m master algorithm # 删除远端分支 要求被删除的分支不能是默认分支 git push --delete origin master # 分支操作 # 列出所有分支,包含远程分支 git branch -a # 删除本地分支 git branch -d branch_name # 删除远程分支 git push remote_name --delete remote_name branch_name # 修改本地及远程分支名称 # 先修改本地分支名 git branch -m oldBranch newBranch # 删除远程分支 git push remote_name --delete remoteName oldBranch # 推送本地重命名后的分支 git push remoteName newBranch # 将修改后的本地分支与远程分支进行关联 git branch --set-upstream-to remoteName/newBranch ```