Startec

Startec

Git and GitHub for Beginners

Mai 26, às 10:19

·

5 min de leitura

·

1 leituras

Introduction 🔍 What is Git? Git is a distributed version control system that can handle small to large scale projects with speed and efficiency. We can use it to do many things, like commit and push...
Git and GitHub for Beginners

Cover image for Git and GitHub for Beginners

Introduction 🔍

What is Git?

Git is a distributed version control system that can handle small to large scale projects with speed and efficiency. We can use it to do many things, like commit and push the projects remotely on GitHub.

What is GitHub?

GitHub is a platform that can be used to host code online. Git is integrated with GitHub, we can use it to do many things, like commit, tag and push the projects remotely on a GitHub repository.

GitHub lets you host your projects and publish them remotely for free.

Getting Started with Git and GitHub 👨🏻‍💻

Installing Git

Git is available for all platforms, like Windows, Mac, Linux, etc. You can download it from here .

Creating a GitHub Account

GitHub is a platform that can be used to host code online. You can create a GitHub account from here .

Creating a Repository

Repository is a place where we can store our projects. We can create a repository on GitHub by clicking on the New button on the top left corner of the screen. New Repository

After clicking on the New button, we will be redirected to a page where we can create a new repository. We can give a name to our repository and make it public or private. We can also add a README file to our repository.

After filling all the details, we can click on the Create Repository button to create our repository. The page will look similar to this after creating the repo:

Repository Page

After filling all the details, we can click on the Create Repository button to create our repository.

Cloning a Repository

Cloning a repository means downloading the repository to our local machine. We can clone a repository by clicking on the Code button on the repository page and copying the link.

Clone Section

After copying the link, we can open the terminal and type the following command to clone the repository:

git clone <link>

Enter fullscreen mode Exit fullscreen mode

After cloning the repository, we can open the folder and start working on our project.

Staging, Committing and Pushing Changes

Staging means adding the changes to the staging area. We can stage the changes by typing the following command in the terminal:

git add .

Enter fullscreen mode Exit fullscreen mode

Committing means saving the changes to our local repository. We can commit the changes by typing the following command in the terminal:

git commit -m "commit message"

Enter fullscreen mode Exit fullscreen mode

Pushing means uploading the changes to our remote repository. We can push the changes by typing the following command in the terminal:

git push 

Enter fullscreen mode Exit fullscreen mode

After pushing the changes, we can refresh the repository page and see the changes.

Creating a Branch

Branch is a copy of the main repository. We can make changes to the branch without affecting the main repository. We can create a branch by clicking on the main button on the repository page and typing the name of the branch. For example, we can create a branch named dev by typing dev in the text box and clicking on the Create branch: dev button. Branch Section

Switching Branches

We can switch branches by clicking on the <'selected repository'> button on the repository page and selecting the branch from the dropdown menu. For example: If dev branch is selected, click on it and switch to other branches like main, etc. Switching Branches

Conclusion

You have successfully learned how to use Git and GitHub. You can now create repositories, clone them, make changes to them, commit and push the changes to GitHub. You can also create branches and switch between them. You can now use Git and GitHub to manage your projects.

Thank you for reading! Happy Coding!


Continue lendo

DEV

CSS code refactoring
To refactor means to restructure the source code of an application or piece of software in order to improve operation without affecting functionality. Programmers should abide by the D.R.Y. (Don’t Repeat...

Mai 27, às 23:23

Hacker News

Google account deleted after 2 hours of Aurora
Recommended alternatives for all the Google products, software and services NOTE: We're trying to recommend you alternatives which are FOSS (or mostly so) and privacy-respecting. This is by no means an...

Mai 27, às 22:20

Discovery

Google Maps completa 18 anos: saiba como tudo começou
O Google Maps, um dos serviços mais icônicos do Google, celebra seu 18º aniversário. Desde o seu lançamento em maio de 2005, ele tem sido uma ferramenta essencial para pessoas ao redor do mundo. Mas como tudo...

Mai 27, às 22:03

Discovery

Como criar um site gratuito no Google Sites
O Google Sites é uma ferramenta gratuita que permite criar um site sem a necessidade de conhecimentos em programação ou design. Com ela, é possível criar um site simples em questão de minutos e compartilhar...

Mai 27, às 21:53

Discovery

Google alerta para dispositivos 'Android TV' vendidos online que não são seguros
O Google está alertando os usuários sobre problemas de segurança relacionados a dispositivos “Android TV” vendidos online que não são seguros. Muitas desses hardwares usam o Projeto de Código Aberto do...

Mai 27, às 21:42

DEV

How to use Firebase Authentication in Next.js 13, Server Side with Admin SDK
I'm new to this world of Full Stack Frameworks like Next.js, SvelteKit, Remix... But I know all the advantages it has so I wanted to use it to create a project I'm working on. I love Firebase and I wanted to...

Mai 27, às 20:20

Marktechpost AI Research News

Meet GANonymization: A Novel Face Anonymization Framework With Facial Expression-Preserving Abilities
In recent years, with the exponential growth in the availability of personal data and the rapid advancement of technology, concerns regarding privacy and security have been amplified. As a result, data...

Mai 27, às 18:38

DEV

Install tool easy by Toolbox
Once suspended, milkcoke will not be able to comment or publish posts until their suspension is removed. Once unsuspended, milkcoke will be able to comment and publish posts again. Once...

Mai 27, às 18:03

IT Forum

Computação quântica pode gerar até US$ 850 bi em receita até 2035 - IT Forum
Imagem: Shutterstock A computação quântica reserva um potencial bilionário para aqueles que saírem na frente em sua adoção. Estudo do Boston Consulting Group (BCG) intitulado Quantum Computing Is Becoming...

Mai 27, às 17:23

Hacker News

Senators issued satellite phones, offered demonstrations on upgraded security devices
Politics Updated on: May 24, 2023 / 10:57 AM / CBS News Amid growing concerns of security risks to members of Congress, over 50 senators have been issued satellite phones for emergency...

Mai 27, às 17:09