全局配置
- 设置用户名
git config --global user.name "YourName"
- 设置用户邮箱
git config --global user.email "YourEmail@Sth.com"
创建空的远程仓库
git clone RemoteRepoSSHAddress
cd YourFolder
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
用本地目录创建远程仓库
cd YourFolder
git init
git remote add origin RemoteRepoSSHAddress
git add .
git commit
git push -u origin master
分支命令
- 克隆远程分支
git clone -b BranchName RemoteRepoSSHAddress
- 查看本地和远程分支
git branch -va
- 查看远程仓库指向
git remote -v
- 重命名本地分支名
git branch -m OldName NewName
- 切换远程仓库
git remote set-url origin NewRemoteRepoSSHAddress