2013-05-23 21:46:11 +0000 2013-05-23 21:46:11 +0000
17
17

GitHub - 完全搞乱了我电脑里gitHub的本地文件。

我在错误的文件夹中创建了一个repo。也就是OS中的User文件夹,从图片、视频到文档,所有的用户文件夹都在这里。所以我在不知情的情况下把这些都推送到了gitHub,现在我不能再创建一个repo了,因为我工作的文件都在文档文件夹里,而文档文件夹是在用户文件夹里面。而且它会暗示我在一个repo中创建一个repo。所以当我进入终端,运行git状态时,它显示出这样的结果:"

0x1"。

# 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,但我删除了它。

有什么建议吗?

答案 (2)

28
28
28
2013-05-23 22:09:13 +0000

首先:

1. 删除你上传用户文件夹的Github远程仓库(你不希望这是公开的) 2. 删除你用户文件夹的本地仓库。 2.[ 删除你用户文件夹中的本地仓库]0x3&。

现在,如果你的本地版本库小于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
1
1
1
2019-03-31 16:41:23 +0000

T递归删除mac os中的.git文件夹,进入包含.git文件夹的项目根文件夹,使用。

find . | grep .git | xargs rm -rf

删除其内容和自身。