git 的使用就无需多说了 我的记录不全 只记录了我能用到的 其他的用到再说吧

基本常用命令

关联 和 取消关联远程仓库

git remote add origin 远程仓库地址
git remote remove origin   取消关联远程仓库地址


克隆项目


git clone https://github.com/****/test.git

进入项目目录


cd test

创建文件 打开文件编辑并保存


touch a.txt
open a.txt


添加


git add a.txt

提交到缓存并添加描述


git commit -m "添加a.txt"


更新代码 允许冲突


git pull origin master --allow-unrelated-histories


提交到远程仓库 输入远程仓库的用户名和密码 OK了


git pull origin master

分支操作

创建新的分支


git branch test1


提交分支到远程仓库


git push origin test1


切换分支


git checkout test1


查看本地分支


git branch


查看远程分支


git branch -a


合并分支


git merge test1


删除本地分支


git branch -d test1


删除远程分支


git push origin --delete test1


tag 标签

查看标签


git tag


添加标签 和 描述


git tag -a 0.1.0 -m '0.1.0标签'


提交到缓存区


git commit


上传所有tag


git push origin master --tags

只记录了工作中常用的命令 其他命令有用到再说吧