01. Setup Repository

git init

To create a new repo, you'll use the git init command. git init is a one-time command you use during the initial setup of a new repo.

  • Executing this command will create a new .git subdirectory in your current working directory, which contains all of the necessary Git metadata for the new repository.

  • This will also create a new master branch.

git init # create repo in current dir
git init <directory> # create repo in <directory> folder
git init --bare # create bare repository

git clone

The git clone command is the most common way for users to obtain a local development clone of a project in a central repository:

  • Like git init, cloning is generally a one-time operation.

  • Once a developer has obtained a working copy, all version control operations are managed through their local repository.

  • Git supports a few different network protocols and corresponding URL formats:

    • Git SSH: git@hostname:username/reponame.git

    • HTTPS: http[s]://host.xz[:port]/path/to/repo.git/

    • GIT: git://host.xz[:port]/path/to/repo.git/

  • git clone will automatically configure your repo with a remote pointed to the Git URL you cloned it from.

git clone <repo url>
git clone -branch new_feature git://remoterepository.git

# Clonning private repo
git clone https://<user-name>@github.com/Narodny-Opros-2020/landing.git

Bare repository

Сырой репозиторий (bare) - это репозиторий в котором есть только git-файлы, но нет рабочей директории. Такие репозитории чаще всего используются в качестве удаленных репозиториев, которые фактически являются средством синхронизации между локальными репозиториями. По соглашению, имя bare-репозитория должно оканчиваться на .git, типа ./bare-repo.git.

Last updated