Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
September 29, 2022 07:41 am GMT

Dude, do the initial Git configuration

Intro

Hello, Let me tell you that I just restarted my work computer, why is this relevant? because I lost all my settings and it's time to configure them again. I imagine you got an idea with the title, we will see the initial git configurations, the ones I need to start working.

I hope this publication is useful to you, I am sure it will be useful for my future self.

what is Git?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. there is more software for version control, but git is the one I like to use.

Initial Configuration

First of all, to start a new repository we can use the command

git init

Now let's set the user information (us).

git config --global user.email "[email protected]"git config --global user.name "your_name"

To find where the settings are stored we can use the command.

git config --list --show-origin

Git works with branches, I'm sure you already know that, as I write this, the default name of the main branch is 'master'. By convention we could call it 'main', let's see how to change the name

git branch -m old_name new_name

to ensure that all projects start with the main branch name 'main'

git config --global init.defaultBranch main

BONUS

For bonus we are going to connect our project to a repository in GITHUB. As a first step we are going to set the 'origin'

git remote add origin repository_URL

To verify that the URL was saved correctly

git remote -v

To fetch the latest version from the remote repository

git pull origin main

if there is an error for different versions we can add the flag '---allow-unrelated-histories'

git pull origin main --allow-unrelated-histories

Finally, to send our information to the remote repository we can do git push and save the changes from our local repository to GitHub

git push origin main

Original Link: https://dev.to/julio_santacruz/dude-do-the-initial-git-configuration-1oao

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To