赞
踩
删除.git
文件夹或许会使我们的git仓库出现问题,如果我们想删除所有的提交记录并保持代码在当前状态可以试试下面的方法:
# Check out to a temporary branch: git checkout --orphan TEMP_BRANCH # Add all the files: git add -A # Commit the changes: git commit -am "Initial commit" # Delete the old branch: git branch -D master # Rename the temporary branch to master: git branch -m master # Finally, force update to our repository: git push -f origin master
按照上面的操作会删除我们旧的提交记录.但如果不生效可以尝试第二种方法.
# Clone the project, e.g. `myproject` is my project repository: git clone https://github/heiswayi/myproject.git # Since all of the commits history are in the `.git` folder, we have to remove it: cd myproject # And delete the `.git` folder: git rm -rf .git # Now, re-initialize the repository: git init git remote add origin https://github.com/heiswayi/myproject.git git remote -v # Add all the files and commit the changes: git add --all git commit -am "Initial commit" # Force push update to the master branch of our project repository: git push -f origin master
原文:Link
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。