git 命令多人协作总结

git pull 出错 fatal: Could not read from remote repository.Please make sure you have the correct access rights.and the repository exists.
Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts.

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

出现这个问题是因为,没有在github账号添加SSH key

1,通过ssh-keygen命令在自己的电脑上生成公钥和私钥;
ssh-keygen -t rsa -C [email protected]
2,进入.ssh文件夹,然后打开id_rsa.pub:
将内容交给你们的git服务器管理员。
然后当他配置好之后就可以访问了。
3,然后就可以使用git clone将远程仓库克隆下来了。
git clone [email protected]/ihotel_qa.git
git本地用户名和密码配置:
$ git config --global user.name "wirelessqa" $ git config --global user.email [email protected]
4,查看远程仓库版本:
ebj1412:ihotel_qa user$ git remote -v origin [email protected]:qa_department/ihotel_qa.git (fetch) origin [email protected]:qa_department/ihotel_qa.git (push)
5,查看远程分支
使用git remote show origin
*remote origin Fetch URL: [email protected]:qa_department/ihotel_qa.git Push URL: [email protected]:qa_department/ihotel_qa.git HEAD branch: master Remote branch: master tracked Local branch configured for 'git pull': master merges with remote master Local ref configured for 'git push': master pushes to master (up to date)
6,拉取远程分支
再使用git checkout -b xxx_xxx remotes/origin/xxx_xxx
7,在远程服务器上创建分支
使用git push -u origin xxx_xxx将本地分支推到服务器
8,删除远程服务器上的分支
如果要删除服务器上的分支git push origin :xxx_xxx
9,查看所有分支
git branch -all
10,多人合作操作解决冲突:
https://segmentfault.com/a/1190000009642318
http://blog.csdn.net/l799069596/article/details/47126503
11,git的常用命令:
http://blog.csdn.net/dengsilinming/article/details/8000622
12,一种是 git rm --cached "文件路径",不删除物理文件,仅将该文件从缓存中删除;
一种是 git rm --f "文件路径",不仅将该文件从缓存中删除,还会将物理文件删除(不会回收到垃圾桶)
假如你有文件不小心commit到了服务器那么你想要删除它,可以使用:git rm -- cached "路径+文件名" , 用-r参数删除目录
git rm -r --cached dirname git commit -m 'say something' git push origin master
一、windows提交到gitHub远程仓库时,错误日志记录:

echo "# hibernateEntity" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/jd2017/hibernateEntity.git
git push -u origin master

D:\JindeWorkspaces\hibernateEntity [master +6 ~0 -0 !]> git remote add origin ht
tps://github.com/jd2017/hibernateEntity.git
fatal: remote origin already exists.
D:\JindeWorkspaces\hibernateEntity [master +6 ~0 -0 !]> git remote rm origin
error: Could not remove config section 'remote.origin'
D:\JindeWorkspaces\hibernateEntity [master +6 ~0 -0 !]> git remote add origin ht
tps://github.com/jd2017/hibernateEntity.git
fatal: remote origin already exists.
D:\JindeWorkspaces\hibernateEntity [master +6 ~0 -0 !]> git remote add origin ht
tps://github.com/jd2017/hibernateEntity.git
D:\JindeWorkspaces\hibernateEntity [master +6 ~0 -0 !]> git push -u origin maste
r
Counting objects: 3, done.
Writing objects: 100% (3/3), 207 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/jd2017/hibernateEntity.git

  • [new branch] master -> master
    Branch master set up to track remote branch master from origin.

提示出错信息:fatal: remote origin already exists.

解决办法如下:

1、先输入$ git remote rm origin
2、再输入$ git remote add origin [email protected]:djqiang/gitdemo.git 就不会报错了!
3、如果输入$ git remote rm origin 还是报错的话,error: Could not remove config section 'remote.origin'. 我们需要修改gitconfig文件的内容
4、找到你的github的安装路径,我的是
C:\Users\Admin\AppData\Local\GitHub\PortableGit_6d98349f44ba975cf6c762a720f8259a267ea445\etc
5、找到一个名为gitconfig的文件,打开它把里面的[remote "origin"]那一行删掉就好了!

参考日志

你可能感兴趣的:(git 命令多人协作总结)