Why Git clone from Gerrit(port 29418) is much slower than Git(port 22) - gerrit

As the title describe.
I made many test on this.
And how can I speed up Gerrit Server?

Once cloned, check what is is fetching with:
time b git fetch --all -v
If you see many origin/branches, you might to cleanup old Gerrit branches in order to not clone/fetch so many branches.
Check also if "Git port 22" refers to the same Gerrit server, or to another Git hosting service: in the latter case, any comparison would be unfair.

Related

How to do I get a log of changes from Bitbucket (like `git log`) but without cloning the repo?

I am looking to run the command git log --since="2 weeks ago" --stat --oneline on a git repository without requiring the clone. I am attempting to track changes made over a time period (using since) down to the specific files to commit.
The by commit is not required but, it is a nice to have. I would prefer to not clone down each repository so interfacing with the Bitbucket API would be optimal. I do have physical access to the git repositories. If required I could use the --git-dir command.

Using git pull properly

I am new to git so please bear with me. I have a rails application on my local machine that I am experimenting with and pushing to the master branch periodically. It works at the moment, but I have fallen behind, and now I am many commits behind the master.
$ git branch
* master
$ git status
On branch master
Your branch is behind 'origin/master' by 27 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
nothing to commit, working tree clean
However, when I use git pull and then start rails, my application breaks with a precompiler error. So I am forced to use git --reset to go back to the local commit before I used git pull.
What is the right way to get around this issue and merge with the latest changes on the master branch? Would one use git --rebase in this case?
Try
git stash
git pull origin master
And once it updates, git stash apply to reapply your local changes
Since nobody has stated this clearly yet: You ask
What is the right way to get around this issue and merge with the latest changes on the master branch?
When you do git pull that does merge the remote changes into your current branch. Whether you would choose to do a rebase instead of a merge (per your other question) is a separate issue, but the default behavior is to combine the two sets of changes (local and remote).
More precisely, by default git pull does a fetch followed by a merge. The exact merge operation depends on configuration and on command-line options, but in a typical configuration where origin/master is upstream of master, saying
git pull
will merge origin/master into master.
So why the errors?
One possibility is that there were merge conflicts. If that happens, git will tell you. If you say git status in this condition, it will tell you that there's a merge in progress and it will indicate which paths (files) need conflict resolution.
Another possibility is that the changes don't conflict (in that they don't affect the same region of the same file) but still don't work properly together. That you would simply have to debug.

git pull from a github repository fork gives conflicts

I have forked rails git://github.com/rails/rails.git at github. My forked repository is at git://github.com/waseem/rails.git. I want to test out some patches submitted by other users to rails mainline. Lets say I want to test out code in migration_status branch at git://github.com/joelmoss/rails.git.
Lets say I
master $ git remote add joelmoss git://github.com/joelmoss/rails.git. and
master $ git remote add mainline git://github.com/rails/rails.git.
I have been pulling from rails mainline into my master.
master $ git pull mainline master
According to http://guides.rubyonrails.org/contributing_to_ruby_on_rails.html#testing-patches I should create a local topic branch and pull in changes from joelmoss/migration_status. So I,
master $ git checkout -b migration_status Create a local topic branch.
And when I do:
migration_status $ git pull joelmoss migration_status
I get a large number of conflicts. I also tried migration_status $ git pull --rebase joelmoss migration_status but I still get conflicts.
In the case of pull --rebase, I think (correct if wrong), git is trying to apply my local changes on top of changes fetched from joelmoss/migration_status. Ideally it should do the opposite. To consider this option, I did following.
master $ git fetch joelmoss
master $ git checkout -b joel_migration_status joelmoss/migration_status and
joel_migration_status $ git rebase master it still gave me lots of conflicts.
How do I pull in patches submitted to one of my local topic branches w/o getting conflicts? I can not resolve those conflicts as I do not know much about what code to keep what not to.
In this case, it looks like joelmoss/migration_status is based off of 3.1.0, which split from mainline/master back in May. So if you merge you're trying to reconcile 4 months worth of development by everyone, in branches that appear to never have been intended to merge.
What you want to do is base your local changes on 3.1 as well. That doesn't guarantee to remove all conflicts, but at least it should be ones you are aware of because it's code you changed directly.
git checkout -b master-3-1 master
git rebase --onto joelmoss/migration_status mainline/master master-3-1

Is there a way I can view changes committed to my local GitHub branch without having to push it to the master branch?

I'm still figuring GitHub and Heroku out, so please bear with me. :)
I've a web app on, say, xyz.com. What I am doing now is to make some code/UI changes on some files, commit those files, push them to the master branch, and then refreshing the url to see these changes.
I think this is obviously the wrong approach, but I don't know of how else to test changes done to my code without having to push them on to the master branch. How could I do so?
I don't quite understand the situation in the full version of your question (see my comment and, as icc asks, why can't you test locally?), but to answer the question in the title, you can see the differences between your master and the version on GitHub by running:
git fetch github
git diff github/master master
(That's assuming that the remote that refers to your GitHub repository is called github - it might well be origin in your case. You can see all your remotes with git remote -v.)
To explain that a little further, when you run git fetch github, git will update all your so-called "remote-tracking branches" - in most cases those are the ones that look like origin/whatever, github/experiment, etc. Those are like a cache of the state of those branches, and they're only updated when you run git fetch or successfully git push to that branch on the remote repository. So, once you've done this to make sure that github/master is a recent snapshot of that branch on GitHub, you can happily compare it with your local master branch using git diff.
First: You don't push to the master branch, you push to a remote repo. You should probably read up on your git.
Second: This is not a good workflow, first you should commit your changes and then test them locally. When you are done testing you are ready to push your commits to a remote repo.

Git / Rails / Shared Hosting (Dreamhost) workflow

This is primarily a question about effective Git usage. I should first say I'm not an expert in Rails (at least in a production sense) and definitely a Git newbie, however, I have had some experience using SVN.
My problem is that I am trying to create a rails application but do not know the best way to keep development local on my computer but be able to deploy to my shared hosting account on Dreamhost.
I figured that Git would allow me to do this, but I am not completely sure how. I was thinking of creating a Git repo on the server and having my local stuff pushed onto it after each commit. I have read a few tutorials on Git, but am still confused on what to do. The alternative to this would be to just use FTP and copy over the files but that doesn't seem right.
Does anybody have a few first steps and/or commands that I can use? Is this deployment method fishy or is there a better way to do this?
I run a Rails website for a brass band in Wisconsin in a very similar setup to what you're describing, though it currently operates out of hostingrails.com. I host my code on github, though there's no reason you couldn't host it privately. My flow has evolved over the last year and a half, so take from this only what you need in the short term.
At the center of my flow, I have set up a semi-elaborate Capistrano script to handle the deployment, including a separate staging environment that makes a whole copy of the production database for testing. This took a while (hours, not days) to build, but it has been so worth it.
My workflow keeps at least 2 branches:
current_release: Live production code. Emergency bugfixes are made here.
master: Finished features ready for release. These features wait here to be tested live. Emergency bugfixes are merged in from current_release.
<feature_name>: Features under development. I try not to have more than 3 of these outstanding at any given time. Emergency bugfixes are merged in, and master is frequently merged in to keep the feature current.
Having this setup allows me to work on several things concurrently. Week-to-week (as this is nowhere near a full-time occupation), I do the following:
I edit in feature branches. I switch back and forth, get bored, get excited, whatever. Sometimes I merge two features that grow together.
[edit]
$ git commit
$ git push github [feature]
Finished features ready for iminent deployment are merged one-at-a-time to the master branch.
$ git checkout master
$ git merge [feature]
[fix immediate problems or inconsistencies]
$ git commit
$ git push github master
$ git branch -d [feature]
I stage the website to a private URL (happens to be stage.madisonbrass.com). The staging environment always pulls from the master branch.
$ cap staging deploy # master is now live at stage.madisonbrass.com
Bam, while I'm testing, I find an emergency bug on the public website. Fortunately, I have current_release working separately, and thus can separately fix and deploy it.
$ git checkout current_release
[fix bug]
$ git commit
$ git push github current_release
$ cap production deploy
I return to the master branch, and start by merging the emergency fix.
$ git checkout master
$ git merge current_release
I continue testing master. Hopefully no new issues appear, but if they do I fix them in master, I merge these changes into current_release and do another production deployment.
$ git checkout current_release
$ git merge master
$ git push github current_release
$ cap production deploy
I tear down my staging environment, lest it somehow get indexed by a search engine.
$ git staging teardown
What I do is have a shared, bare Git repository (created with git init --shared --bare) which is the "master" repository and is where I push my work. A bare repository does not have a working directory. For my web directory, I clone the master repository so it has a working directory and all the files are there. From there, I git pull any new work that I've committed.
I always do development work on a separate machine with a clone of the repository and a test development environment. When I've finished a feature, I push it up to the master and then log in to the production server and pull it to the working directory there.
This is just me for not-terribly-important projects. One could extend this with many more steps and checks and balances for Important Work.
I'd recommend using GitHub and keep your Dreamhost resources as free as you can to run your Rails app (in fact, depending on your project, I'll need as much as it can have to coup with it, being a shared hosting).
My usual workflow involves having a development environment and a GitHub account. We use Capistrano (which is fairly simple to learn and understand) to manage the push to GitHub, and then the respective deployment to the hosting, in your case Dreamhost, through SSH/SCP.
That way, you won't have to worry about what it's actually on your production repository, neither having to do maintenance tasks on it. Works pretty fast too and can easily be adapted for when you decide to change hostings o servers.

Resources