1

I ran git pull on my local branch to pull new branch but with error:

warning: There are too many unreachable loose objects; run 'git prune' to remove them.

Then I checkout'ed to new branch anyway but every files disappeared. I tried running git prune, git gc and deleting .git/.gc_log but no luck.

➜  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)
Hangai
  • 307
  • 2
  • 14

1 Answers1

0

Your branch is behind 'origin/master' by 7 commits, and can be fast-forwarded.

If your local/master have no important commits that you have not pushed yet then you can do hard reset your local/master with origin/master.

$ git checkout master
$ git reset --hard origin/master

Is it possible delete EVERYTHING on local and pull a fresh new copy?

Say, you want to sync your local feature branch with your origin/feature branch. Then at first delete your current local feature branch then create a new feature branch with origin/feature history.

$ git checkout master
$ git branch -D feature                   # delete local 'feature' branch

$ git fetch                                
$ git checkout -b feature origin/feature  # create new feature = origin/feature

Note: Replace feature with the name of local branch

Sajib Khan
  • 22,878
  • 9
  • 63
  • 73
  • Master branch has some of its files now. But others still don't have anything in it but .gitignore. Is it possible delete EVERYTHING on local and pull a fresh new copy? – Hangai Apr 19 '17 at 16:14
  • You can delete your local branch (say, `feature`) then create a new local `feature` branch with the history of `origin/feature`. Updated answer. – Sajib Khan Apr 19 '17 at 16:20