git clone from local to remote

We’re in the process of migrating from Mercurial to Git for our workflow and I have two minor issues.

First, is it possible to “clone” a local repository directly into an empty remote (ssh) dir?

  • Azure git deployment failure
  • Jenkins triggered code deploy is failing at ApplicationStop step even though same deployment group via code deploy directly is running successfully
  • Automatically deploying assets to Rackspace CDN via git and updating references to those assets?
  • Cannot push to heroku - bundler fails
  • Subversion Partial Export
  • deployable wiki-based documentation
  • Currently when we create a new website we basically clone our CMS locally, configure it and then we clone it on the central repo and on the webserver (hg clone . ssh://account@server/www). That way we have instant access to push/pull goodness.

    This brings me to the second issue, remote deployment.

    Currently with Mercurial, I have a simple hooks in the remote repos that execute hg up when a changeset is received.

    To do the same with Git I’ve followed the instructions here: but I’d like to keep the .git directory in the website root as it is the case with Mercurial (it’s protected by Apache config and I can’t export GIT_DIR for all accounts as some have more than one website/repos).

    Is it possible to have basically the same setup without separating the working dir from the repos?

  • Using gitosis to specify permissions per branch?
  • Fix “unknown repository” of an opened PR after deleted the fork
  • Why does Zipping the same content twice gives two files with different SHA1?
  • How to set up p4merge as diff tool for Visual Studio 2015 | git
  • How to split folders of a git repo into separate branches?
  • Does TortoiseGit allow selective staging, like git-gui?
  • 6 Solutions collect form web for “git clone from local to remote”

    To answer your first question, yes, you can. Suppose the remote directory is ssh://user@host/home/user/repo. This must be a git repository, create that with git init --bare or scp your local repo.git (can be created with git clone) directory to remote. Then do:

    git remote add origin ssh://user@host/home/user/repo
    git push --all origin

    This will push all locally-existing branches to the remote repository.

    To get to your next question, you should be able to do the same thing by using a different set of commands. Try these:

    $ cd /var/www  # or wherever
    $ mkdir somesite
    $ cd somesite/
    $ git init
    $ git --bare update-server-info
    $ git config receive.denycurrentbranch ignore
    $ cat > hooks/post-receive
    git checkout -f
    $ chmod +x hooks/post-receive

    You would, of course, run the remote/push commands above after this step. You may have to check out a specific branch after doing so, so that the “somesite” clone on the server actually knows which branch to follow. From then on out, pushing to that repository should trigger a re-checkout of that branch.

    I also ran into this issue recently and solved it as follows:

    On remote server:

    1: Create a directory named /tmp/bare
    2: Change to that directory

    3: Execute git init –bare

    On local machine:

    1: Change to your git project directory
    2: git remote add bare ssh://user@server/tmp/bare
    3: git push –all bare
    4: git remote remove bare

    On remote server:

    1: git clone /tmp/bare /path/to/your/clone

    On local machine:

    1: git remote add origin ssh://user@server/path/to/your/clone

    This is a little involved, but it works and does not require setting any weird flags or instructing git to override its default behaviours. It is hence quite safe.

    This answer is good but I was not able to get it to work for me. The following code from this link did On the remote run

    mkdir my_project.git
    cd my_project.git
    git init --bare
    git-update-server-info # If planning to serve via HTTP

    Locally on an existing repository that already has at least one commit run

    git remote add origin
    git push -u origin master

    I hope this helps anyone that had problems with the other answer.

    Easiest git equivalent to hg clone . ssh://account@server/www is:

    rsync -avz . ssh://account@server/www/reponame

    In fact, I have added this line to ~/.bash_aliases to mirror any directory anywhere:

    alias mirror="rsync -avz . ssh://account@server`pwd` --delete"

    It could prove dangerous if you happen to be in a special directory like /dev or /bin.
    Be careful.

    I agree with, and improve on presto8 by deleting unmatched files.

    rsync -avz . ssh://account@server/www/reponame --delete

    Just to give you an alternative, you can use:

    git remote set-url origin git://

    These also work if your local git respository is pointing to another remote repository

    Git Baby is a git and github fan, let's start git clone.