Recent Changes - Search:

Basics

Languages

Tools

OS

Resources

PmWiki

pmwiki.org

edit SideBar

Git /

Setting up a Git repository

Once you have configured Git, you can start creating a repository. There are a few ways to do that, depending on your situation.

Starting from scratch

If you have not yet started to work, or if you are the first person to use Git to track changes on something, setting up your repository is dead easy. First create the directory in which you want to work, then, inside that repository:

git init

will initialize your repository. You can then create or copy the files you want to work on, and start using git?.

Cloning a repository

If you already have started to work with version control, or are joining someone who is, and would now like to work on a new computer, you need to clone the original repository. This will automatically copy all the files contained in the original directory, as well as the information about the origin, so that the new repository can access to original one.

This is accomplished through

git clone origin target
ex.: git clone mycolleague

where origin can be a local directory or, more likely, a remote directory accessed over a network or the internet. Note that git will refuse to clone a repository if the target directory is not empty. If you are accessing a remote repository, you can use the same syntax as with scp?:

git clone username@domain:Path/To/Repo LocalRepo

Cloning in a non-empty directory

Although this looks like a messy idea at first, it can be useful to keep scripts up to date in a certain directory that also has other things, for example. In this case, the way to do things is a bit different: You create a repository, add a new origin to it, fetch? the remote repository's information and get the files from it. This looks like:

git init
git remote add origin username@domain:Path/To/Repo
git fetch
git checkout -t origin/master
Edit - History - Print - Recent Changes - Search
Page last modified on July 30, 2015, at 06:55 PM