Create your first repository, then add and commit files.

1)First Step

Open command line, first verify that you have Git installed:

On all operating systems:

git --version

On UNIX-like operating systems:

which git

If nothing is returned, or the command is not recognized, you may have to install Git on your system by downloading and running the installer.

See the Git homepage for exceptionally clear and straightforward installation
instructions.After installing Git, configure your username and email address. Do this before making a commit.Once Git is installed, navigate to the directory you would like to put under version control and make an empty Git repository:

git init

This creates a hidden folder, .git, which contains the plumbing needed for Git to work.
Next, check what files Git will add to your new repository; this step is worth special care:

git status

Review the resulting list of files; you’ll tell Git which of the files to put into version control (avoid adding files with confidential information such as passwords, or files that just clutter the repo):

git add <file/directory name #1> <file/directory name #2> < …>

If all files in the list should be shared with everyone who has access to the repository, a single command will add everything in your current directory and its subdirectories:

git add .

This will “stage” all files to be added to version control, preparing them to be committed in your first commit.For files that you want never under version control, create and populate a file named .gitignore before running the add command.Commit all the files that have been added, along with a commit message:

git commit -m "Initial commit"

This creates a replacement commit with the given message. A commit is sort of a save or snapshot of your entire project.

You can now push, or upload, it to a foreign repository, and later you’ll jump back thereto if necessary.If you omit the -m parameter, your default editor will open and you’ll edit and save the commit message there.

Adding a remote
To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at.The git remote add command

git remote add origin

If you like this post, don’t forget to share šŸ™‚

This article is written by our awesome writer
Comments to: Create your first repository in git

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Join our Newsletter

Get our monthly recap with the latest news, articles and resources.

By subscribing you agree to our Privacy Policy.

Latest Articles

Explore Tutorials By Categories


Codeverb is simply an all in one interactive learning portal, we regularly add new topics and keep improving the existing ones, if you have any suggestions, questions, bugs issue or any other queries you can simply reach us via the contact page


Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
    Strength indicator
    Log In | Lost Password