Dude, do the initial Git configuration

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 "your@email.com"
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
Total
1
Shares
Leave a Reply

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

Previous Post
types-of-data-loss-prevention-you-need-to-know

Types of Data Loss Prevention You Need to Know

Next Post
best-ways-you-can-use-onboarding-for-newly-hired-developers

Best Ways You Can Use Onboarding for Newly- Hired Developers

Related Posts