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.
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.
First of all, to start a new repository we can use the command
Now let's set the user information (us).
git config --global user.email "firstname.lastname@example.org" 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
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