使用git 时遇到问题及解决方法

git pull 时报错fatal: No remote repository specified.

$ git pull
fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.
复制代码

找不到对应库,可能库地址配置错误。

因为我之前设置了默认分支medicalcard,又太久没pull过代码,该分支在远程库上已被删除,所以pull 失败。 解决方法:在\.git\config中设置要重新设置默认分支

[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	symlinks = false
	ignorecase = true
[remote "ds"]
	url = http://git.daishujiankang.com:88/ds/tijian.git
	fetch = +refs/heads/*:refs/remotes/ds/*
# 该分支已删除
-[branch "medicalcard"] 
-	remote = ds
-	merge = refs/heads/medicalcard
+[branch "master"]
+	remote = ds
+	merge = refs/heads/master
复制代码

同理,远程库地址、默认push地址、默认合并地址都可以在这里进行设置

恢复某个版本误删文件

  1. 找到在是误删的版本号
  2. git checkout <commit>回退到该版本,此时会产生个以该版本号命名的临时分支
  3. 找到该文件后,再 git checkout <commit>到回退前的版本,此时会产生个以该版本号命名的临时分支
  4. 切换到doctor_report分支,再合并3中的临时分支
14922@DESKTOP-0LSVJK1 MINGW64 /c/wamp/www/tijian.git (report)
$ git checkout 48eddc2
Note: checking out '48eddc2'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
  git checkout -b <new-branch-name>
HEAD is now at 28a52a046... 我的钱包接口更换
---
14922@DESKTOP-0LSVJK1 MINGW64 /c/wamp/www/tijian.git ((48eddc2ce...))
$ git checkout  97fdddf13
Previous HEAD position was 48eddc2ce... 优化录音toast图片更改方法 
HEAD is now at 97fdddf13... [报告解读] 消息撤回功能
---
14922@DESKTOP-0LSVJK1 MINGW64 /c/wamp/www/tijian.git ((97fdddf13...))
$ git checkout doctor_report
Previous HEAD position was 97fdddf13... 恢复误删chat-input.less
Switched to branch 'doctor_report'
---
14922@DESKTOP-0LSVJK1 MINGW64 /c/wamp/www/tijian.git (doctor_report)
$ git merge 97fdddf13
Updating 7aea28c9e..97fdddf13
Fast-forward
 .../common/component/chat-input/chat-input.less    | 124 +++++++++++++++++++++
 1 file changed, 124 insertions(+)
 create mode 100644 apps/report/wechat_miniapp/compile/page/common/component/cha                        t-input/chat-input.less

复制代码

转载于:https://juejin.im/post/5ba101bd5188255c5e66dae8

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值