我对GIT并不是这样,我有以下问题。
我有一个在GIT下的Java项目,并且与远程BitBucket存储库相关联。问题是,对于错误,我删除了 .git 文件夹(我无法检索它)。
我可以以某种方式生成与此存储库关联的新.git文件夹吗?
答案 0 :(得分:3)
两种方式:
你可以简单地clone the repo again using:
git clone http://your/repo/url
或者您可以重新初始化git文件夹和create the connection between your local folder and the repo manually:
git init // initializes the .git dir
git remote add origin http://your/repo/url // adds your bitbucket repo as origin url
git remote -v // verify it worked and the connection is stable
git pull origin master // pull and see if your up-to-date
... // do whatever you like from here, add, commit, push
答案 1 :(得分:1)
由于本地仓库与bitbucket连接,您最好将此仓库克隆到另一个目录,然后将当前更改的文件复制到其中。最后提交并推送更改为bitbucket。
如果您创建了新的.git
文件夹,则所有提交历史记录都将丢失。如果您不需要历史记录,那么您可以在空路径中创建.git
文件夹,然后将文件移动到此路径中。
答案 2 :(得分:0)
只需为你的Github项目做一个新的克隆。将创建一个新的.git
文件夹。