git版本上传

git提交时
git commit -a -m"sssssss"


如果写成


git commit -m"sssssss"回车了


git push origin master


然后出现了下面的错


Counting objects: 29, done.
error: inflate: data stream error (unknown compression method)
error: unable to unpack 8ddef......................... header
Delta compression using up to 4 threads.
Compressing objects: 100% (26/26), done.
error: inflate: data stream error (unknown compression method)
fatal: loose object 8ddef9c................ (stored in .git/objects/8d/def9c03e8230...........................) is corrupt
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
fatal: write error: Bad file descriptor
error: failed to push some refs to 'https://.................. /ssss.git'


使用
git push -f origin master
也不行也出现上面的错




那么用如下的git语句就可以解决


1.   输入  


 $ rm -fr .git


等半天出现
sss@DESKTOP-sss MINGW64 /e/project/sss
然后再输入


2.  输入


 $ git init


出现
Initialized empty Git repository in E:/project/sss/.git/


sss@DESKTOP-sss MINGW64 /e/project/sss(master)


3.在输入:
$ git remote add origin https://.............../ssss.git


ssss@DESKTOP-sss MINGW64 /e/project/sssss(master)


4.再输入:


$ git fetch


出现
remote: Counting objects: 1961, done.
remote: Compressing objects: 100% (806/806), done.
remote: Total 1961 (delta 1044), reused 1797 (delta 973)
Receiving objects: 100% (1961/1961), 4.62 MiB | 1.05 MiB/s, done.
Resolving deltas: 100% (1044/1044), done.
From https://.................../ssssss
 * [new branch]      master     -> origin/master


ssss@DESKTOP-sss MINGW64 /e/project/sssss(master)


5. 再输入:


$ git reset --hard origin/master


HEAD is now at 630817f 提交退出登录出现白色页面以及我的页面的图片问题


ssss@DESKTOP-sss MINGW64 /e/project/sssss(master)


6. 再输入:


$ git branch --set-upstream-to=origin/master master


出现:
Branch master set up to track remote branch master from origin.


ssss@DESKTOP-sss MINGW64 /e/project/sssss(master)


然后重启你的开发工具就好了

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

本文记录一下如何在Xcode中使用Git作为源代码控制工具,以及如何将本地的Git仓库和远程Github上的仓库集成起来,虽然这章节和Swift没有关系 ,但我还是放在这里。觉得学swift 这个也很关键。

1、xcode中使用git源码控制

目前版本的饿xcode(xcode 4 以上)都集成了源代码控制(Source Control)工具了,所以为新建的项目使用git来管理是很方便的。

我们只要在新建项目的时候勾选下图的checkbox 
这里写图片描述
xcode就自动为我们创建了,git源代码管理。我们项目目录里应该就又.git文件夹了。如果没有。可以显示隐藏文件看看。

defaults write com.apple.finder AppleShowAllFiles TRUE
 
 
  • 1
  • 1

这时候 我们的Source Control ,就可以有很多操作了。 
这里写图片描述
如果要给以前的项目添加git,先到项目目录

cd /Users/YOUR-USERNAME/Desktop/NoGitExample 
 
 
  • 1
  • 1

然后

git init
 
 
  • 1
  • 1

这会初始化一个空的源,如果你在Finder里面查看或是输入ls命令,你会看到.git子目录已经被创建,很好,接下来输入:

git add .  
 
 
  • 1
  • 1

这样,当前目录所有的内容就被添加到源里面去了,最后,输入以下命令:

git commit -m 'Initial commit’  
 
 
  • 1
  • 1

这样就给项目加上git了 。对详细的git操作可以看在Xcode中使用Git进行源码控制 
讲得很详细,很好。前面都是摘取它里面的片段 。

2、. 如何将Xcode的本地Git仓库与Github的远程仓库集成

Github的理念源自于Git,二者并非完全一致的。但是从版本控制方面来说,差别不大。所以利用Xcode内置的Git管理功能即可与Github连接,而无需额外安装Github客户端。

我们可以使用SSH连接,使用非对称公钥认证方法。将xcode与github链接起来 。 当然不连接起来应该也可以 。不过要每次输入用户名密码麻烦 。

ssh-keygen -t dsa -f ~/.ssh/id_dsa
 
 
  • 1
  • 1

会提示你输入密码。两次

Your identification has been saved in /Users/xx/.ssh/id_dsa.
Your public key has been saved in /Users/xx/.ssh/id_dsa.pub.
 
 
  • 1
  • 2
  • 1
  • 2

然后提示你这两句 。我们去/Users/xx/.ssh/id_dsa.pub. 这个文件中找到public key 一长串字母

也可以直接使用这个命令查看 cat ~/.ssh/id_dsa.pub

然后进git官网登录后点击自己头像-->Settings->SSH keys->add Key

然后title 随便写一个 ,把那一长串字母 复制到key中 。

then , 在控制台测试.ssh dz$ ssh -T git@github.com 
如果出现

 Hi xxxxx! You've successfully authenticated, but GitHub does not provide shell access.
 
 
  • 1
  • 1

证明成功了 !

这里有可能出现这个错误Permission denied (publickey) 
可以试试这个方法

你只要修改/etc/ssh/sshd-config文件,将其中的PermitRootLogin no修改为yes,PubkeyAuthentication yes修改为no,AuthorizedKeysFile .ssh/authorized_keys前面加上#屏蔽掉,PasswordAuthentication no修改为yes就可以了。
 
 
  • 1
  • 1

这个是网上的方法 ,/etc/sshd-config 我的文件是这样的结构。没有ssh那个层级

然后就是为本地项目添加远程地址了 。 
这里写图片描述

然后到下面这个界面

这里写图片描述

Name根据自己喜好写吧 , Address 写githubrepositorie

这里写图片描述 
直接在这里复制就行了。 
然后就是push了 ,别说你找不到push!!Source Control 子菜单

在这里有可能报一个错(xcode 6 )

Could not read from remote repository.Please make sure you have the 。。。。。。。。
 
 
  • 1
  • 1

如果是 xcode 7 ,可能会报

The local repository is out of date.
Make sure all changes have been pulled from the remote repository and try again.
 
 
  • 1
  • 2
  • 1
  • 2

别担心 , 是因为你再github新建的项目中有readme.md 在本地没有造成的,需要将它pull下来

在终端,先进入到你项目目录,cd 。。。。。。 
git pull命令的作用是,取回远程主机某个分支的更新,再与本地的指定分支合并

git pull <远程主机名> <远程分支名>:<本地分支名>
 
 
  • 1
  • 1

现在已经在项目当前目录了 。

git pull --rebase xxx master
 
 
  • 1
  • 1

xxx 是Add Remote 的Name master 是你的分支名称 默认是master

我就遇到这么多问题 , 如果你遇到别的奇葩问题。自行解决。。

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

本文讲的是把Git在最新2.9.2,合并pull两个不同的项目,出现的问题如何去解决fatal: refusing to merge unrelated histories

我在Github新建一个仓库,写了License,然后把本地一个写了很久仓库上传。

先pull,因为两个仓库不同,发现refusing to merge unrelated histories,无法pull

因为他们是两个不同的项目,要把两个不同的项目合并,git需要添加一句代码,在git pull,这句代码是在git 2.9.2版本发生的,最新的版本需要添加--allow-unrelated-histories

假如我们的源是origin,分支是master,那么我们 需要这样写git pull origin master ----allow-unrelated-histories需要知道,我们的源可以是本地的路径

知识共享许可协议
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。欢迎转载、使用、重新发布,但务必保留文章署名林德熙(包含链接:http://blog.csdn.net/lindexi_gd ),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请与我联系


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值