Github 删除远端分支的某个文件或文件夹

刚开始创建的时候搞错了几个文件和文件夹,后来想在clion上面弄,发现不是很方便,还是要用命令行,解决办法:

  1. 已经下载好的话就进入你的仓库路径,比如你github 上面仓库名字是XXX,那么就进入XXX路径:
cd XXX

否则就进入存放你新建的git文件路径YYY

cd YYY
  1. 然后git拉下远端分支:
git pull origin master

在这里插入图片描述

  1. 查看当前分支下面具体有什么文件和文件夹,搞清楚自己要删除什么东西!
dir
  1. 确定自己是不是在要修改的分支上!
git branch
  1. 开始动手删除文件和文件夹:
rm -rf <your files and folders>
  1. 回到原来的文件路径下面(参考第一条的路径):
cd XXX(YYY)
  1. 打包到本地仓库:
git add .
  1. commit自己修改的内容
git commit -m "remove error filefolders and files"

假如出现下面的情况,提示也有说,按照操作办就好了。
在这里插入图片描述

*** Please tell me who you are.
Run
  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'sph@sph-Computer.(none)')
  1. 然后就push啦,错误的指令是:
git push master

会出现下面的错误:

warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

fatal: 'master' 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 push -u origin master

在这里插入图片描述

  1. 搞定。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

晚餐男孩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值