Git常见的一些报错

2 篇文章 0 订阅

今天在使用gitee上传项目时,遇到了一些报错,下面做下记录:

中间或许有很多不必要的步骤,大家看看,有则改之,无则加勉

一. not a git repository (or any of the parent directories): .git
翻译:不是git仓库(或任何父目录):.git
解决办法:

  1. 如果是第一次创建,就输入git init 指令,见表格该文件夹初始化为一个本地仓库
  2. 如果不是第一次创建(一般指我们已经克隆了一个仓库),这时候可能是因为我们没有进入到仓库文件夹,只需进入到仓库文件夹即可

我的问题就是第二点,没有进入到仓库对应的文件夹,这时候在终端输入 cd “你的文件路径”,
例如:cd bkk74_308(这里有一个快捷键,输入b,然后按下tab件就会自动补全该文件夹名)

在这里插入图片描述

这时候我们可以输入git status查看状态和是否存在.git文件
在这里插入图片描述
上面的提示:Untracked files:
(use “git add …” to include in what will be committed)

翻译:无路径的文件:

(使用"git add …"来包含将要提交的内容)

我们试一下,输入git add .
在这里插入图片描述
出现上面这种情况,原因就是,你在一个github仓库里面,放进来一个文件夹,(这里的myClassTest)但是文件夹里面还有文件夹(wangyiyun),而且还没有提交过的。

这个时候我百度了一下,拜读了一篇博客就是这一篇,我照着他说的做了一下,但是问题依然没有解决,这个时候我看到了下面这篇博客删除.git文件夹,我去自己的文件夹里看一看,并没有发下.git文件夹

在这里插入图片描述
这个时候,我的第一念头就是,这个文件夹会不会被隐藏了,我这里使用的是win10系统,下面看看是不是吧,显示隐藏文件夹步骤:

  1. 打开要检查的文件夹(这里就是你的仓库)
  2. 点击左上角菜单栏部分的查看
  3. 在显示/隐藏部分选择显示隐藏的项目
    在这里插入图片描述
    然后运行git add 指令时 又来了not a git repository (or any of the parent directories): .git,无限循环,令款头大,我再试试另外一种方法,就是直接把wangyiyun这个文件夹放进仓库中试一下

然后,试了一下
git add . ——> git commit -m “备注信息” -----> git push成功了

此博客,仅是自己遇到的一个问题,解决了自己的一个问题,解决问题的过程中,也学到了一些东西。可能与大家遇到的问题相同,但具体细节并不一定完全一致,解决方案也不见得适用于所有人,但是,有两句话,我觉得挺好的,就是遇到问题了第一时间要想到的是自己解决、自己处理,而不是张嘴去问别人,只有这样我们才能掌握解决困难,处理问题的能力。

配置用户名、密码

昨天我还遇到了一个问题,就是在上传项目时,提示让我输入自己的用户名 和 密码,这个问题,今天坐到我旁边的刚来的小伙子也遇到了这个问题,这个问题其实很简单,就是简简单单的两行指令,就可以搞定了,截图我已经没有了,指令可以给大家

局部:

git config user.name “username”
git config user.email “email”

全局就是加上-global

git config --global user.name “username”
git config --global user.email “email”

  • 21
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 13
    评论
Title: Git Version Control Cookbook Author: Aske Olsson, Rasmus Voss Length: 273 pages Edition: 1 Language: English Publisher: Packt Publishing Publication Date: 2014-08-25 ISBN-10: 1782168451 ISBN-13: 9781782168454 90 hands-on recipes that will increase your productivity when using Git as a version control system Overview Filled with practical recipes that will teach you how to use the most advanced features of the Git system Improve your productivity by learning to work faster, more efficiently, and with more confidence Discover tips and tricks that will show you when and how to use the advanced features of Git In Detail Starting with the Git data model, you will learn how Git stores files and how it looks at commits. You will then learn how you can recover from mistakes; from committing on the wrong branch to recovering lost commits/files. Next, you will discover how you can force rebase on some branches and use regular Git merge on other branches. You will also learn how to extract information from the repository. As you progress through this book, you will learn how you can automate the usual Git processes by utilizing the hook system built into Git. The book also covers advanced repository management, including different options to rewrite the history of a Git repository. Finally, you will discover how you can work offline with Git, how to track what is going on behind the scenes, and how to use the stash for different purposes. What you will learn from this book Understand the Git data model and how you can navigate the database with simple commands Learn how you can recover lost commits/files Discover how you can force rebase on some branches and use regular Git merge on other branches Extract metadata from a Git repository Familiarize yourself with Git notes Discover how you can work offline with Git Debug with Git and use various techniques to find the faulty commit Approach This practical guide contains a wide variety of recipes, taking you through al

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值