使用Git bash遇到的一些问题解决方法

使用Git bash遇到的一些问题解决方法

1.warning: LF will be replaced by CRLF in package.json.(原因是存在符号转义问题)
The file will have its original line endings in your working directory.
解决:git config --global core.autocrlf true(当 core autocrlf为true时,还有一个需要慎重的地方,当你上传一个二进制文件,Git可能会将二进制文件误以为是文本文件,从而也会修改你的二进制文件,从而产生隐患)

2.On branch master
Your branch is ahead of ‘origin/master’ by 1 commit.
(use “git push” to publish your local commits)

nothing to commit, working tree clean(其根本原因是版本分支的问题)

3.当 git push origin branch_name时遇到报错如下:

fatal:‘origin’ does not appear to be a git repository

fatal:Could not read from remote repository

原因:

本地分支和远程分支断开连接

解决方法:
cd 本地分支里
(1)、git branch
——*master 只显示master

然后查看是否从上游拉了
(2)、git remote –v
——若什么都没有,则和上游已断联系,拉不了代码也推不了代码

加关联
(3)、git remote add origin ssh://git@pandaliusir.github.io(地址)

然后
(4)、git fetch origin
——会显示下拉的branch情况
再次检查远程仓库,显示对应的clone地址
git remote –v
——origin git://github.com/schacon/ticgit.git (fetch)
origin git://github.com/schacon/ticgit.git (push)

然后再查分支
git branch –a

    ——* mater

4.master合并分支时提示“Already up-to-date”
(git pull origin master
From https://github.com/pandaliusir/pandaliusir.github.io

branch master -> FETCH_HEAD
Already up to date.)
在使用Git把当前分支合并到master提示“Already up-to-date”,但当前分支和 master 分支代码不同步。假设当前分支是:dev,主分支是:master。
解决方法:
git checkout master;
git reset --hard dev;
git push --force origin master

5.在执行git pull origin master时出现:
  fatal: ‘origin’ does not appear to be a git repository
  fatal: Could not read from remote repository.
  Please make sure you have the correct access rights and the repository exists

解决方案:
git remote add origin git@github:bx_reader/bx-reader-api.git

将关联远程仓库为origin,然后再输入:
git push -u origin master
就可以提交了

ssh-keygen -t rsa -C “your@email.com”(填写自己的邮箱地址)回车
接下来会出现:(一路回车就可以)
  Generating public/private rsa key pair.
  Enter file in which to save the key (/root/.ssh/id_rsa):
之后打开提示的目录
C:\Users\liusi.ssh
记事本打开
id_rsa.pub,
复制里面内容
进入自己的账号https://github.com/settings/keys 点击 New sshKey,复制的内容粘贴到Key里,标题可以不写。

验证:$ ssh -T git@github.com回车
  Hi XXXXX! You’ve successfully authenticated, but GitHub does not provide shell access.
  成功
6.git将本地内容传送到远程仓库出现[rejected] master -> master (fetch first)错误
问题:使用git push -u 远程库名 master 命令将本地提交的内容传到git远程库时出现错误:

命令: git push -u origin master

出现错误:
  To https://github.com/imjinghun/university.git
  ! [rejected] master -> master (fetch first)
  error: failed to push some refs to ‘https://github.com/imjinghun/university.git’
  hint: Updates were rejected because the remote contains work that you do
  hint: not have locally. This is usually caused by another repository pushing
  hint: to the same ref. You may want to first integrate the remote changes
  hint: (e.g., ‘git pull …’) before pushing again.
  hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.

解决:git pull --rebase origin master
git push origin master

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值