Git使用总结
Github创建项目,这个子安github上创建就OK了。
本地:
git init
git add something #这里其实最好添加 .ignore文件
git commit -m “description”
git remote add origin gitAddress
git push -u origin master
本地创建分支 提交到远程仓
git checkout -b localBranchName #创建分支
git push origin localBranchName:netBranchName #:左右不能有空格
多人操作
git clone gitAddress
git checkout origin/netBranchName -b localBranchName #拉去远程分支同时创建本地分支同时切换到新创建的本地分支
git push origin localBranch:netBranch #push的时候 local在前 net在后
问题处理
! [rejected] localspace -> workspace (fetch first)
error: failed to push some refs to 'git@github.com:hzj7510/testGit.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
git pull #执行pull拉去信息 全部是这样的 git pull origin netBranch:localBranch #这里net branch在前面
处理冲突
git add .
git commit -m “commit info”
git push origin localBranch:netBranch
删除远程分支
git push origin :netBranch #注意:前不填写任何本地分支 只在写:后的net branch
到这里基本够用了。
参考资料
git拉取远程分支到本地分支或者创建本地新分支
手把手教你使用Git
强烈推荐-Git远程操作详解
Issue pushing new code in Github
网友评论