使用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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。