BitBucket repo larger after using BFG repo cleaner - git-rewrite-history

My BitBucket repo had a whole bunch of large files in that weren't needed. I removed them and then wanted to clear them out from the history to shrink down the repo which had gotten too big.
I ran BFG repo cleaner which reported 1755 files found and processed - all the ones I was expecting.
Ran the final git gc as instructed here: https://rtyley.github.io/bfg-repo-cleaner/
All fine - the .git folder shrunk to 17% its original size.
Pushed it back up and the repo size as reported by BitBucket actually got larger!
Not sure what went wrong as all seemed to behave correctly up to that point.
Any advice gratefully received as I really don't want to have to recreate the repo to bring down the size.
Thanks

As suggested by #peter, you need git gc to run on the hosted repository before you will see size changes. If in the interim you clone this repository and it has been cleaned-correctly, your clone should reflect the eventual size.
For self-hosted Stash you can probably trigger a gc, for hosted bitbucket.org the schedule is not published nor can it be influenced.

Related

BFG-repo-cleaner and pushing back to GitHub

I'm trying to follow the tutorial instructions here : https://rtyley.github.io/bfg-repo-cleaner/
I clone a new copy of my github based repo with --mirror
I follow the instructions for running bgf and reflog
My local repository has now removed the big blog. Great.
When I go to push back to github I get
To github.com:interstar/myproject.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git#github.com:interstar/myproject.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
So I try to git pull from github to ensure sync. (Even though this repository was cloned cleanly from github at the start of the process)
And it pulls down all the blobs I want to get rid of. So my repo is back up to its previous size.
So I run bfg and reflog again. Nice small repo.
Try to push back to github
Same error message.
What am I missing?
OK.
I solved this. It was my own stupid fault, but leaving the question in case anyone else does the same thing.
Although the first time I cloned the repo from github I used --mirror, at some point I tried again and forgot to use the --mirror option.
When I started over with that option it worked as the tutorial suggested.

Mercurial and TortoiseHg: How to push a fresh copy without pulling

So here's the sitch:
I am working on a Unity game project with a few others. We are using Tortoise with a repo hosted on BitBucket. One of the other people pushed a version with a huge amount of unnecessary files that we had previously deleted. I'd like to revert his push if possible. Ideally, without having to pull what he has pushed because I don't want to spend 20 mins downloading all of these extra files just to get rid of them again.
Is there any way to do this? Is it possible to push my current commit as a fresh copy to the repository?
Thanks in advance for any help
Actually, if the files were previously in your project and then deleted, they will be in your local copy of the repo already. The repo includes all the history for your project. You could see them if you did an "hg update" to a past version which included those files.
That said, to revert the change use BitBucket's web interface:
How do I delete/remove a push from Bitbucket?

Is it possible to convert a googlecode hg repository to a largefile repository?

I have a remote hg repository hosted on googlecode. Thus I don't have admin access to run e.g. lfconvert on it (as far as I know), and of course lfconvert can only be used on local repositories.
So, is there any way to a convert an googlecode hg repository to a largefile repository?
(one idea is to convert a local clone of the repo to a largefile repo and then push the changes to the "central" googlecode repo, but I fear trying that without knowing if it is a valid approach).
Using your idea to do a local conversion and push, you can take advantage of the 'reset' feature for your repositories:
Do a local clone.
Convert to largefiles: `hg lfconvert normal_repo largefiles_repo``. Do NOT delete the original clone until you are sure everything works.
Reset the hosted repository (See https://code.google.com/p/support/wiki/MercurialFAQ#Mercurial_FAQ).
Push the largefiles repository.
Pushing the largefiles repository without reseting seems problematic because the largefiles repository is essentially a fork of the original one starting at the point the first largefile was committed.
If the push fails*, you can push the original clone and you'll be back where you started without any data loss. (One of the many advantages of DVCS. :-))
The big downside of course is that everybody who has ever cloned your project will now be working from a different fork of the repository. This is always a danger when you do anything involving changing history and is the motivation for Mercurial phases. If you want to be 'kinder', you can start a second project for the largefiles version and place a link at the original project cite describing the move.
[*] I can't figure out from Google Code's documentation whether the largefiles extension is supported. There is a reviewed feature request, but I couldn't find any mention of the request actually being implemented. The push failing would probably be a good indication that largefiles isn't supported though...

hg-git can pull from forked repo, but not original repo

I'm using TortoiseHg with the hg-git Mercurial plugin to interact with Github without using Git at all, only Hg. On Github, I forked the pandas repo. I successfully cloned my fork to my computer. I want to add the original pandas repo as a URL in Hg, so I can pull changes from that repo and integrate them with whatever changes I make myself. I added the original pandas repo in the URLs in TortoiseHg under the name "upstream".
However, if I try to pull from that original upstream repo, Hg hangs for a long time and then eventually issues a "504 - Gateway timeout" error. If I directly clone the pandas repo (instead of cloning my fork of it), I can pull from it fine.
The strange thing is that this doesn't seem to happen with all repos. I did the same process (fork, clone the fork, then try to pull from the original) with the matplotlib repo, and it seems to pull from the original repo just fine.
Even stranger, if I clone the original repo, and then add my fork as an extra URL, I can pull from both. So somehow the URL as set during the original clone is okay, but setting the same URL manually as a source doesn't work.
This seems to indicate that the problem is with the pandas repo specifically. Is this possible? Is there some setting on Github that could be affecting my ability to pull from that repo? What can I do to make it work?
I repeated the process with hg-git via the command line and couldn't replicate the problem. So there are a few possibilities:
There's either an issue with (your) TortoiseHG (config).
You've made a typo of some type when entering the URL into TortoiseHG.
There's a weird corner case in hg-git.
Something is causing trouble in your hgrc -- either your global one (hidden in your home directory) or your repository specific one (found in .hg/hgrc).
If you provide your hgrc files as a Github Gist (anonymizing them as need be), that might provide some insight.
In the meantime, one solution is to do the git stuff by hand and then force an update:
cd path/to/hg/repo
git fetch https://github.com/pydata/pandas.git # equal to hg pull,
hg gimport # pulls the changesets from the hidden git repo into the mercurial repo
If this works, then there's probably something wrong with the saved URL.
You still have to worry about merging and rebasing and whatnot, but you can do that within Mercurial. The hidden git repo will be automatically when you do a push to a git remote, or you can force it to update via hg gexport.

Repository is changed after push on mercurial

When I create repository and push on server and when we clone the repository in local system the files are come with red signal means they are changed.
When we compare both repository I found that the content of files in .hg folder is changed.
Can anyone pls tell me how to remove this problem!
Edit:
When we change the .hg folder the red icon becomes green!!!!
If you take 1 modified (changed) file, watch the diff closely, and only see the difference is in new lines only, this is the classical newlines mess.
(happens to most people when working crossplatform)
There is a ready to use Mercurial Extension, taking care of this is problem.
It's called eol.
Learn how to use it and the problem from here:
https://www.mercurial-scm.org/wiki/EolExtension
how do you push localy created repository to server? If there is no repo with same name(on server), you could not be able to create remote repo by push, you have to clone it to the server. Or, if there already is repository with same name, and you push some new localy created, there definitely will be something more in .hg on the server then on the local. Check if there isn't repo with same name on the server already. HTH