Git 从我的本地项目中不再存在的 repo 中删除特定文件夹
Git delete specific folder from repo that doesn't exist anymore on my local project
我想从我的 bitbucket 存储库 中删除一个在我的本地项目文件夹中不再存在的特定文件夹。
我不想使用 git commit -a 提交所有内容,因为我仍在处理某些事情,我也不想提交它我忽略了很多 files/folders 并且不确定是否所有内容都包含在 .gitignore 中(由于大小 我只提交了项目的一部分 .. ).
所以现在我不想提交所有内容,而是想定位一个特定的文件夹并将其从我的存储库中删除。我是一个 git 初学者 ..这一定是一些我不知道的简单解决方案,这个问题可以在某个地方提出但找不到任何好东西..或者我做错了什么。
有什么建议吗?
注意 1:您应该提交。您的提交只会出现在您的本地存储库中,而不会出现在 bitbucket 中。您可以稍后在推送到原点之前对其进行修改。
注意 2:您可能应该学习在 git 上使用分支。它们重量轻且易于使用 - 它将使您能够轻松切换工作环境。
注意 3:您可以使用 git 存储,但我觉得提交您的工作可能更好。
所以我的回答是:
$ git checkout -b my-temporary-branch # create local branch for your work
$ git add -A # add everything, that you worked on
$ git commit -m "AMEND ME LATER"
$ git fetch
$ git checkout -b temporary-master origin/master # I don't know what you committed
# to your local master already,
# that's why we're switching
# to whatever was pushed to
# bitbucket already
$ git rm -rf <directory name>
$ git commit -m "Directory removed."
$ git push origin master # publish your changes to bitbucket
$ git checkout my-temporary-branch # back to branch
$ git branch -D temporary-master # remove unnecessary branch
然后继续你的工作;您可以使用
修复最后一次提交
$ git commit --amend
请注意,在将新工作推回母版之前,您需要在 origin/master 中的更改之上进行合并或变基。
我想从我的 bitbucket 存储库 中删除一个在我的本地项目文件夹中不再存在的特定文件夹。
我不想使用 git commit -a 提交所有内容,因为我仍在处理某些事情,我也不想提交它我忽略了很多 files/folders 并且不确定是否所有内容都包含在 .gitignore 中(由于大小 我只提交了项目的一部分 .. ).
所以现在我不想提交所有内容,而是想定位一个特定的文件夹并将其从我的存储库中删除。我是一个 git 初学者 ..这一定是一些我不知道的简单解决方案,这个问题可以在某个地方提出但找不到任何好东西..或者我做错了什么。
有什么建议吗?
注意 1:您应该提交。您的提交只会出现在您的本地存储库中,而不会出现在 bitbucket 中。您可以稍后在推送到原点之前对其进行修改。
注意 2:您可能应该学习在 git 上使用分支。它们重量轻且易于使用 - 它将使您能够轻松切换工作环境。
注意 3:您可以使用 git 存储,但我觉得提交您的工作可能更好。
所以我的回答是:
$ git checkout -b my-temporary-branch # create local branch for your work
$ git add -A # add everything, that you worked on
$ git commit -m "AMEND ME LATER"
$ git fetch
$ git checkout -b temporary-master origin/master # I don't know what you committed
# to your local master already,
# that's why we're switching
# to whatever was pushed to
# bitbucket already
$ git rm -rf <directory name>
$ git commit -m "Directory removed."
$ git push origin master # publish your changes to bitbucket
$ git checkout my-temporary-branch # back to branch
$ git branch -D temporary-master # remove unnecessary branch
然后继续你的工作;您可以使用
修复最后一次提交$ git commit --amend
请注意,在将新工作推回母版之前,您需要在 origin/master 中的更改之上进行合并或变基。