Git Create Operation - Git (software)

What is Git Create Operation?

In this chapter, we will see the way to create a remote Git repository; from now on, we are able to refer to it as Git Server. We need a Git server to allow team collaboration.

Create New user

The above command will produce the following result.

Create a Bare Repository

let us initialize a new repository through the use of init command observed by --bare option. It initializes the repository without a working directory. through convention, the bare repository should be named as .git.

Generate Public/Private RSA Key Pair

let us walk through the method of configuring a Git server, ssh-keygen application generates public/private RSA key pair, that we will use for user authentication.

Open a terminal and enter the subsequent command and just press input for every input. After successful completion, it'll create a .ssh listing in the home directory.

The above command will produce the following result.

ssh-keygen has generated two keys, first one is private (i.e., id_rsa) and the second is public (i.e., id_rsa.pub).

Note: never share your private KEY with others.

Adding Keys to authorized keys

Suppose there are two developers working on a project, namely Tom and Jerry. both users have generated public keys. allow us to see the way to use these keys for authentication.

Tom introduced his public key to the server by the use of ssh-copy-id command as given below:

The above command will produce the following result.

The above command will produce the following result.

Push Changes to the Repository

We have created a bare repository on the server and allowed access for 2 users. any longer, Tom and Jerry can push their adjustments to the repository by way of adding it as a remote.

Git init command creates .git listing to save metadata about the repository whenever it reads the configuration from the .git/config file.

Tom creates a new listing, provides README file, and commits his change as initial commit. After commit, he verifies the commit message by using running the git log command.


The above command will produce the following result.

Tom checks the log message by executing the git log command.

The above command will produce the following result.

Tom committed his adjustments to the local repository. Now, it’s time to push the adjustments to the remote repository. however before that, we need to upload the repository as a remote, that is a one-time operation. After this, he can properly push the adjustments to the remote repository.

Note: through default, Git pushes best to matching branches: For each branch that exists on the local aspect, the remote aspect is updated if a branch with the equal name already exists there. In our tutorials, every time we push adjustments to the origin master branch, use suitable branch name according to your requirement.

The above command will produce the following result.

Now, the changes are successfully committed to the remote repository.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Git (software) Topics