我在我的本地分支上运行git pull
以获取新分支,但出现错误:
warning: There are too many unreachable loose objects; run 'git prune' to remove them.
然后我checkout
转到了新的分支,但每个文件都消失了。我尝试运行git prune
,git gc
并删除.git / .gc_log但没有运气。
➜ gerege git:(nissan) git status
On branch nissan
Your branch is up-to-date with 'origin/nissan'.
nothing to commit, working directory clean
➜ gerege git:(nissan) git pull
Username for 'https://git.nmma.co': khangarid.d@nmma.co
Password for 'https://khangarid.d@nmma.co@git.nmma.co':
remote: Counting objects: 73, done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 73 (delta 31), reused 0 (delta 0)
Unpacking objects: 100% (73/73), done.
From https://git.nmma.co/Gerege/gerege
db33f62..2ec26ab discovermongolia -> origin/discovermongolia
* [new branch] ecrc -> origin/ecrc
a286063..a05fbb9 master -> origin/master
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
error: The last gc run reported the following. Please correct the root cause
and remove .git/gc.log.
Automatic cleanup will not be performed until the file is removed.
warning: There are too many unreachable loose objects; run 'git prune' to remove them.
Already up-to-date.
➜ gerege git:(nissan) git checkout ecrc
Branch ecrc set up to track remote branch ecrc from origin.
Switched to a new branch 'ecrc'
➜ gerege git:(ecrc) gco master
Switched to branch 'master'
Your branch is behind 'origin/master' by 7 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
答案 0 :(得分:0)
你的分支在7个提交后面是'origin / master',可以快进。
如果您的local/master
没有重要提交但尚未推送,那么您可以使用local/master
硬重置 origin/master
。
$ git checkout master
$ git reset --hard origin/master
是否可以删除本地的所有内容并提取新的副本?
说,您想要将本地feature
分支与您的origin/feature
分支同步。然后,首先删除当前的本地feature
分支,然后创建一个新的feature
分支,其中包含origin/feature
个历史记录。
$ git checkout master
$ git branch -D feature # delete local 'feature' branch
$ git fetch
$ git checkout -b feature origin/feature # create new feature = origin/feature
注意:将feature
替换为本地分支的名称