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

版权声明:本文为博主夏日辉的原创文章,未经博主允许不得转载。 https://blog.csdn.net/shanpenghui/article/details/89197379

刚开始创建的时候搞错了几个文件和文件夹,后来想在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 "[email protected]"
  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. 搞定。

猜你喜欢

转载自blog.csdn.net/shanpenghui/article/details/89197379
今日推荐