Git – Remote site to local

I have a new client wordpress site, which was built in a bit of a mess (but it works).

I have installed Git on the remote server and on my local machine.

  • Linking repo subfolders with git
  • Before I start developing locally, I need all documents from remote server copied to my local server.

    How do I do this using Git please?

    I am a git noob, so please go easy on me… Is it as simple as…

    REMOTE SERVER:

    git commit -m "Initial Pull"
    

    LOCAL SERVER:

    git pull website master
    

    I know I can just copy files over using FTP, but I wish to have the local and remote servers to be synched / Version Controlled before I start coding away.

    Or have I completely misunderstood the purpose of Git?

    Update:

    assuming that my username is harry and my server domain name is potter.co.uk and the git repository is in /home/harry/site.git could you confirm if this will work? Will I break anything if I try this out on my local machine?

    git clone harry@potter.co.uk:/home/potter/site.git
    

  • Using Git, if during a newfeature branch, when we need to do a hot fix, should we create a hotfix branch?
  • Delete remote branch displayed on local by 'git branch -a'
  • Git directed acyclic graph - children know their parents but not the other way around
  • Cloning private git repo in the docker container
  • removing file from git history doesn't work
  • Does tidying your code warrant an individual Git commit?
  • 2 Solutions collect form web for “Git – Remote site to local”

    you want to use git clone

    git clone username@server:path/to/repo.git

    If you are going to be working with several repos, I would add an entry to your ~/.ssh/config file

    Host git
    HostName myserver.com
    IdentityFile ~/.ssh/id_rsa
    User mygituserid
    

    Then you can just do

    git clone git:/path/to/repo.git

    In either case, remember that the path after the : is relative to the ssh user’s home dir without a leading /

    Also, if you want to push back changes to REMOTE the remote repo should be bare. To convert to a bare execute (as per @jthill’s comment)

    git clone --mirror existing_repo repo.git
    

    Then i would clone that new,bare repo to my local machine before beginning work.

    The precise question was answered by @scott. Take a look at git’s homepage, it references several books, a bunch of good tutorials, and a lot of other resources. It is a bit tricky to use (specially if you are accustomed to SVN or some other centralized version constrol system), so I’d suggest you set up a few repositories for experimentation (not that git looses information; it can do so if you ask forcefully enough, though; it is that the user can get confused enough that they don’t know how to untangle the mess). Don’t be shy in having several copies of the repository on your machine, perhaps an “official” one and others to try out possibly dangerous stuff. OTOH, you can create those on the fly (git operations, even cloning a full repository, are uncannily fast).

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