Thursday, July 16, 2020

Create a local Git Repository

How to create a remote GIT repository and connect to it.

Git Repository provides storage of project files managed by git. There is a set of notes maintained at Notes on Git.

To setup a project with support for Git, use the following command, in the same folder as the project root folder.

git init

The basic configuration for a username and email is required, to access any remote git repositories. 

git config --global user.name "Tboxmy"
git config --global user.email "username@gmail.com"

There are many more configurations. Another example, for MS Windows PC that wants to preserve its end of line format, we can use

git config --global core.autocrlf false

In order to have a centralised repository, where one or many users can send changes to their files from other computers, we use a remote repository. This centralised repository is known as Bare Repository where users can send their project files over. Use the following command.

git init --bare <repo_name>.git

Then users can connect to this remote repository, and keep their files updated there.
git remote add <remote_name> <remote_repo_url>

In order to update remote repository with changes in files, a user can PUSH files there

git push -u <remote_name> <local_branch_name>


No comments:

Blog Archive