1、初始新建git,出现No refs in common and none specified; doing nothing
解决方案:Perhaps you should specify a branch such as 'master',指定master
2、主分支更新了,但是其他分支还是旧的?
3
3、远程已经建立仓库,提交本地目录的时候出现error: src refspec master does not match any
原因在于没有进行add和commit,在进行add和commit之后解决这个问题
4、git URL readonly
git仓库中配置使用ssh管理,SSH Keys,故进行git clone时候需要使用ssh协议
5、无写权限
因为ssh-keyes配置使用自己的用户名
6、冲突合并
[root@typhoeus82 git_test]# git checkout master
Switched to branch 'master'
Your branch and 'origin/master' have diverged,
and have 1 and 1 different commit(s) each, respectively.
[root@typhoeus82 git_test]# git merge iss53
Auto-merging index.html
CONFLICT (add/add): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
自动合并后的内容:
[root@typhoeus82 git_test]# more index.html
<<<<<<< HEAD
aaaa
=======
xxxxx
bbb
>>>>>>> iss53
7、远程仓库更新了之后,本地再次提交新的修改
[root@typhoeus82 git_test]# git push
To git@10.210.213.9:code_guosong/git_test.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@10.210.213.9:code_guosong/git_test.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
You have new mail in /var/spool/mail/root
使用git pull,然后进行git push
[root@typhoeus82 git_test]# git pull
Merge made by recursive.
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test
[root@typhoeus82 git_test]# git push
Counting objects: 17, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (14/14), 1.16 KiB, done.
Total 14 (delta 5), reused 0 (delta 0)
remote: => Syncing Gitorious... [OK]
To git@10.210.213.9:code_guosong/git_test.git
02549fa..b40b323 master -> master
8、在commit log中看到异常的邮箱
commit b699f0d6d9ac5e0eba153cfe76426a54f7aa866b
Author: lwjydcg <lwjydcg@163.com>
Date: Fri Oct 24 20:38:49 2014 +0800
os_parameter server_resource
一般内网的搭建git,推荐使用本人邮箱前缀和邮箱设置为公司邮箱,出现上面的问题是由于没有配置user.name和user.email导致
可以看到邮箱和可以对应上
使用git config --global user.name 和git config --global user.email进行修改即可
对于上面异常的user.emal,可以使用unset进行删除
git config --global --unset user.emal
9、取消本地部分文件的修改
9.1 存在本地修改
使用git stash会将本地所有文件的修改都取消了
使用git reset,git reset是将commit的东西重置
使用git checkout -- <file>解决问题
10.删除远程分支
git branch -d dev dev2
这个只删除本地的分值
如果需要删除远程的分支需要使用下面的命令:
git push origin :branch-name
冒号前面的空格不能少,原理是把一个空分支push到server上,相当于删除该分支。
11、问题
guosongdeMacBook-Air:auth guosong$ git pull
fatal: No remote repository specified. Please, specify either a URL or a
remote name from which new revisions should be fetched.
【参考资料】
1、http://blog.youkuaiyun.com/hutaoer06051/article/details/8275069