git-基本操作命令

130 阅读1分钟

1. 克隆代码

git clone [address]
git clone -b [branchame] [address]

2. remote操作

git remote //查看当前所有remote
git remote -v //查看remote详情
git remote add [name] [address] //增加远程仓库
git remote show [name] //显示远程仓库信息
git remote remove [name] //删除远程仓库在本地的信息
git remote rename [oldname] [newname] //修改名字

3. 拉取操作

git pull
git pull [origin] [branch]

4. 推送操作

git add .
git commit -m "注释"
git push [remote-name] [branch-name]

5. 分支操作

git branch //查看本地所有分支和当前分支
git branch -m [oldname] [newname] //修改
git branch -d [name] //删除本地分支
git branch -D [name] //强制删除本地分支
git push [remote-name] -d [name] //删除远程分支并推送到服务器
git checkout [branch-name] //切换到该分支
git checkout -b [name] //创建新分支并切换到该分支

6. 合并操作

git merge [branch-name]//将该分支下的代码合并到当前分支