我在错误的文件夹中创建了一个 repo。意思是 OS 中的 User 文件夹,其中的所有用户文件夹都是图片、视频和文档。所以我在不知情的情况下将所有内容推送到 gitHub,现在我无法再创建 repo,因为我使用的文件位于文档文件夹中,该文件夹位于 User 文件夹中。这意味着我正在 repo 中创建 repo。因此,当我进入终端并运行 git status 时,它会显示以下内容:
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 2 and 4 different commits each, respectively.
#
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: Documents/m3/m3---Best-Game-Ever
# deleted: Documents/of_v0072_osx_release/apps/myApps/CCLab_2/cclab_sketch_1/src/Boxes.cpp
# deleted: Documents/of_v0072_osx_release/apps/myApps/CCLab_2/cclab_sketch_1/src/Boxes.h
# deleted: Documents/of_v0072_osx_release/apps/myApps/ball_bouncing/Ball.cpp
# deleted: Documents/of_v0072_osx_release/apps/myApps/ball_bouncing/Ball.h
# deleted: Documents/of_v0072_osx_release/apps/myApps/bouncing_ball_classes/src/ball.cpp
# deleted: Documents/of_v0072_osx_release/apps/myApps/bouncing_ball_classes/src/ball.h
# deleted: Documents/of_v0072_osx_release/apps/myApps/ms_final/src/backGround.cpp
# deleted: Documents/of_v0072_osx_release/apps/myApps/ms_final/src/backGround.h
# deleted: Documents/of_v0072_osx_release/apps/myApps/ms_final/src/backGround2.cpp
# deleted: Documents/of_v0072_osx_release/apps/myApps/ms_final/src/backGround2.h
# deleted: Documents/of_v0072_osx_release/apps/myApps/mySketch/src/backGround.cpp
# deleted: Documents/of_v0072_osx_release/apps/myApps/mySketch/src/backGround.h
# deleted: Documents/of_v0072_osx_release/apps/myApps/mySketch/src/backGround2.cpp
# deleted: Documents/of_v0072_osx_release/apps/myApps/mySketch/src/backGround2.h
# deleted: README.md
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .Trash/
# .bash_history
# .dropbox/
# .openmdao/
# .ssh/
# Documents/2nd_semester/
# Documents/Arduino/
# Documents/OpenMDAO/
# Documents/Personal/
# Documents/T.A/
# Documents/gitHub/
# Documents/mySite/
# Documents/openFrameworks/
# Documents/resources/
# Documents/webcam-pulse-detector-master/
# Dropbox/
# Library/
# Music/
no changes added to commit (use "git add" and/or "git commit -a")
不用说,我永远无法提取任何东西。它说一切都是最新的。在某个时候,我有一个 repo,将那些没有文件的文件夹上传到 gitHub,但我删除了它。
有什么建议么?
答案1
首先要说的是:
- 删除Github远程仓库您上传用户文件夹的位置(您不希望公开)
删除本地存储库在您的用户文件夹中。
# Be careful, dangerous command, it will erase your repository # Make sure that you run this from the right folder rm -rf .git
现在,如果你的本地存储库重新Documents
开始工作你完成了否则,逐个删除并克隆它们(当然,这将丢弃未提交的更改和您之前未推送的提交)。
cd ~/Documents/gitHub/
# example, and again, be careful, it will erase your entire folder
rm -rf repositoryA
git clone git://github.com/myUser/repositoryA.git
rm -rf repositoryB
git clone git://github.com/myUser/repositoryB.git
# And so on
答案2
T.git
递归删除 mac os 中的文件夹,转到包含.git
文件夹的项目的根文件夹并使用:
find . | grep .git | xargs rm -rf
删除其内容和其本身。