Git遇到的一点错误

【背景】

折腾:

【记录】将googlecode上面的crifanLib迁移到Github上

期间出错:

?

?


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18


[email protected] /cygdrive/e/dev_root/git/crifanLib

$ git remote add origin https://github.com/crifan/crifanLib.git

[email protected] /cygdrive/e/dev_root/git/crifanLib

$ git remote -v

origin  https://github.com/crifan/crifanLib.git (fetch)

origin  https://github.com/crifan/crifanLib.git (push)

[email protected] /cygdrive/e/dev_root/git/crifanLib

$ git push origin master

Username for https://github.com:

Password for https://[email protected]@github.com:

To https://github.com/crifan/crifanLib.git

 ! [rejected]        master -> master (non-fast-forward)

error: failed to push some refs to https://github.com/crifan/crifanLib.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.

出错了。

很明显是:

本地没有update到最新版本的项目(git上有README.md文件没下载下来)

本地直接push所以会出错。

【解决过程】

1.看到提示里面,感觉是本地的代码不是最新的。

所以觉得应该是类似于svn中的,先update一下,再去commit,估计就可以了。

所以先去pull试试:

结果直接pull好像是不对的:

?


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26


[email protected] /cygdrive/e/dev_root/git/crifanLib

$ git pull

warning: no common commits

remote: Counting objects: 6, done.

remote: Total 6 (delta 0), reused 0 (delta 0)

Unpacking objects: 100% (6/6), done.

From https://github.com/crifan/crifanLib

 * [new branch]      master     -> origin/master

You asked me to pull without telling me which branch you

want to merge with, and ‘branch.master.merge‘ in

your configuration file does not tell me, either. Please

specify which branch you want to use on the command line and

try again (e.g. ‘git pull <repository> <refspec>‘).

See git-pull(1) for details.

If you often merge with the same branch, you may want to

use something like the following in your configuration file:

    [branch "master"]

    remote = <nickname>

    merge = <remote-ref>

    [remote "<nickname>"]

    url = <url>

    fetch = <refspec>

See git-config(1) for details.

看来需要先搞懂pull的用法。

2.估计是指定对应的要pull的目标即可。

所以再去试试pull origin:

?


1

2

3

4

5


[email protected] /cygdrive/e/dev_root/git/crifanLib

$ git pull origin

You asked to pull from the remote ‘origin‘, but did not specify

a branch. Because this is not the default configured remote

for your current branch, you must specify a branch on the command line.

也还是不对。

有空再继续搞懂原理后再弄。。

3.搜:

error: failed to push some refs to

参考:

github – git error: failed to push some refs to – Stack Overflow

去试试:

?


1

2

3

4

5

6


[email protected] /cygdrive/e/dev_root/git/crifanLib

$ git pull --rebase origin master

From https://github.com/crifan/crifanLib

 * branch            master     -> FETCH_HEAD

First, rewinding head to replay your work on top of it...

Applying: add local crifanLib to github

可以看到,此时已经把github上最新的文件下载下来了:

即,那个README.md文件。

4.接着再去:

git push origin master

?


1

2

3

4

5

6

7

8

9

10

11


[email protected] /cygdrive/e/dev_root/git/crifanLib

$ git push origin master

Username for https://github.com:

Password for https://[email protected]:

Counting objects: 19, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (14/14), done.

Writing objects: 100% (18/18), 112.33 KiB, done.

Total 18 (delta 0), reused 0 (delta 0)

To https://github.com/crifan/crifanLib.git

   6bae951..32d67c7  master -> master

即可成功把本地的文件都上传到github上面去了。

5.此时再去github网站上也就可以看到对应文件了:

【注意】

此处注意到,此时所用的用户,是那个当前电脑的名词,很长的那个,而不是crifan:

那是因为之前那个:

【已解决】cygwin中用git去config配置用户名和邮箱出错:error: cannot run vi: No such file or directory

时,当时没有解决掉用户名的问题就去commit了。

所以用户名是当时的,当前电脑的用户名。而不是我自己的crifan。

而此时已经解决了修改用户名的问题。

等下次再去上传,或许可以把用户名变过来了。

时间: 2024-07-29 02:49:24

Git遇到的一点错误的相关文章

git提交代码出现错误fatal: Unable to create &#39;项目路径/.git/index.lock&#39;: File exists.

git提交代码出现错误fatal: Unable to create '项目路径/.git/index.lock': File exists. 具体出错代码如下: 具体原因不详,在stackoverflow上查找了很久,也不清楚原因,但是stackoverflow给出了解决的方法. 解决方法: 在当前项目下打开git bash,运行如下命令: rm -f ./.Git/index.lock 只为成功找方法.大胆的尝试,下一个fun就是你的fun! git提交代码出现错误fatal: Unable

git ,报403错误,完美解决方案

首先命令行操作结果如下: [email protected]:/zrun# git clone https://git.coding.net/xxxxxxxx/xxxx.git正克隆到 'anbu'...remote: Coding.net Tips : [You have no permission to access this repo.]fatal: unable to access 'https://git.coding.net/xxxxxxxx/xxxx.git/': The requ

git 提交出现这个错误fatal: Unable to create &#39;project_path/.git/index.lock&#39;: File exists.

git 提交出现这个错误fatal: Unable to create 'project_path/.git/index.lock': File exists. exists 解决办法 rm -f ./.git/index.lock on Windows del .git\index.lock git 提交出现这个错误fatal: Unable to create 'project_path/.git/index.lock': File exists.

让git忽略ssl证书错误

让git忽略ssl证书错误 当你通过HTTPS访问Git远程仓库,如果服务器的SSL证书未经过第三方机构签署,那么Git就会报错.这是十分合理的设计,毕竟未知的没有签署过的证书意味着很大安全风险.但是,如果你正好在架设Git服务器,而正式的SSL证书没有签发下来,你为了赶时间生成了自签署的临时证书,怎样才是最便捷的测试手段. 一种比较好的做法: 第一步,克隆远程仓库时,用env命令设置GIT_SSL_NO_VERIFY环境变量为"ture",并同时调用正常的git clone命令.完整

git push的一个错误

我在把我的本地分支push到远程仓库的时候,一直失败,错误提示是: $ git push origin masterTo [email protected]:xiaxiaosheng/AndroidRemoteCtrl_Client.git ! [rejected] master -> master (non-fast-forward)error: failed to push some refs to '[email protected]:xiaxiaosheng/AndroidRemoteC

解决git push远程分支错误

分布式版本控制系统在日常开发中使用越来越频繁,谁没经历过手一抖,不小心把错误的内容git push到远程仓库? 前几天我就遇到了,当时对git也不熟,于是各种try--终于,现在搞明白了 环境: 远程仓库fork的开发项目 分支只有master 操作: git pull origin master (埋下祸根,把别人的commit也pull下来了) git push self master:master repo中merge 请求,包含别人的commit ! 解决办法: 新建临时分支git ch

git clone出现SSL错误

在学习git的时候,发现不能使用git clone从github.com下载,报了个ssl错误. Cloning into cancan... error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://

Git 学习笔记--删除错误提交的commit

如果不小心把错误的commit给commit了,可以对其进行撤销 1.使用git log查看commit日志,找到错误提交前一版本commit的哈希值; 2.使用git reset --hard commit_id; 3.git push origin HEAD --force(git push --force) 将修改提交到git服务器

git更新代码出现错误

git  pull代码时,出现如下的错误: SSL certificate problem: unable to get local issuer certificate 主要的原因是:没有ssl证书,直接采用https的方式进行更新 解决方案如下: 配置好git的环境变量后,在控制台执行如下命令即可: git config --global http.sslVerify false