[git-users] Re: How to prevent git repo to get big file history back

2013-03-21 Thread Johan 't Hart


On Wednesday, March 20, 2013 7:34:18 PM UTC+1, Ashutosh Kumar wrote:

 Hi,

 I am working on removing big file from my git repo and its history as 
 well. But i am facing one issue ..

 here is my scenario

 1. Create a repo
 2. Commit and push a big file
 3. Clone the repo in to test_clone1
 4. Clone the repo in to test_clone2
 5. Remove the big file’s history (commit and push) in test_clone1

I'm guessing you do this with filter-branch right?
 

 6. Commit and push a test file in test_clone2

Here is the problem. Before you could push with test_clone2 you probably 
had to pull first. Because the latest commit ID's did not match (because of 
filter-branch), the 2 commits are merged together. And presto, the big-file 
is merged back. Now push, and the big-file is back in the upstream branch.

This can be avoided, but you have to do that manually in every repo that 
has the big file cloned. Do as follows:
Fetch the upstream changes (git fetch) (so you get the upstream branch 
without the big file)
Reset the current branch to the upstream branch (git reset --hard 
origin/master)

When there were already changes made that needed to be pushed, you have to 
cherry-pick those changes. The easyest way to do this is via the gui.
gitk HEAD@{1}
Right-click a change to be cherry-picked, and select cherry-pick.

When done, you can push again. And repeat the steps for every clone.

7. Clone the repo in to test_clone3 — I believe the big file’s history will 
 have come back.

Yep, its been merged in by test_clone2
 

 Do you have any idea, what we can do to neglect this issue if that git 
 repo is using by many users?

For many users you have to tell them what to do to get rid of the big file. 
Or hand them a script that could do it for them.

Good luck! 


 Thanks,

 Ashutosh.


-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[git-users] Re: How to prevent git repo to get big file history back

2013-03-21 Thread Johan 't Hart
Another way you might have a chance of getting rid of the big file:

- Do a filter-branch (to get rid of big file)
- Create a helper branch
- Reset it to the place where the big file was first committed (I mean, not 
before that commit, but right on it)
- Now create a dummy empty file with the same name as the big file
- git commit --amend -C HEAD
- switch back to the original branch
- rebase on the helper-branch (git rebase helper)
- push

What you have done now is that the big file in the tree is replaced by an 
empty file. Other users who now try to pull, get a merge conflict. You have 
to tell them to for once do a 
git pull --rebase -srecursive -Xtheirs
Please test this all first, because I'm not sure whether this will work.

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.