How to Start Using Git and GitHub

How to Start Using Git and GitHub

How to Start Using Git and GitHub ?


Step 1 – Install Git


Git comes preinstalled in some Macs and Linux-based systems, but you can always check if you have Git installed in your machine by typing git version in your terminal.


You can use the Command Prompt to do this.


As you can see above, I have Git version 2.31.1 installed on my Windows computer. If you don't have Git installed in your computer, you won't get a version.


You can download Git?here : https://git-scm.com/download.


Follow the necessary installer guide until installation is complete.


Open the command prompt and type?git version?to verify that Git was successfully installed.


Step 2 – Create a GitHub Account.


To create an account on GitHub, you will be asked for some personal information like name, confirm your email, set a username and password, and your account should be set up in minutes.


Create an account on : https://github.com/


Step 3 – Connect your GitHub account to your Git account.


You'll do this from your terminal.


To set your Git username, type this in your terminal:

git config --global user.name "John Smith"


To confirm that you have set your Git username correctly, type this:

git config --global user.name


You should have "John smith" as the output.



To set your Git email, type this in your terminal:

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


To confirm that you have set your Git email correctly, type this:


git config --global user.email


You should have "[email protected]" as the output.


You will be asked to authenticate your GitHub account, so just sign in with the same email to confirm.


Step 4 – Create and edit your code files locally


Step 5 – Create a repository on GitHub


Click the + sign at the top right corner to create a new repository. Repositories are like your code folders online.


Step 6 – Push your local code to GitHub

You can use the code editor built-in terminal to use Git to push your code to GitHub. Click ctrl + shift + ' to open the terminal in VSCode.


echo "# sample-code" >> README.md

git init

git add .

git commit -m "first commit"

git branch -M main

git remote add origin https://github.com/montassarrrkefi/sample-code.git

git push -u origin main


Note that we have git add README.md?in the repository on GitHub. But here we have git add . , which is to let Git add all our code files instead of the README.md file which will be created by echo "# sample-code" >> README.md.

So if you have created other files in your local folder, you need to use git add . to add all files.


Take note that git remote add origin https://github.com/montassarrrkefi/sample-code.

git will contain the link to your own repository and it will have have the name of your GitHub account.


Common Git Commands to Know

They are many Git commands you can use in the terminal, and that can get overwhelming. So I'd suggest focusing on some of the most popular ones first.

Here they are:

git init?lets you initialize Git in your folder.

git add?Readme.md?lets you add the Readme file, while?git add .?lets you add all files in the present folder.

git commit?stores the added files.

Use?-m?for message followed by the actual message.

git branch?creates a new branch which is a new version of the repository as it appears when added, and?-M?to move the name to?main.

git remote add origin?finally connects the local folder to the repository on GitHub. It is followed by the repository's link.

git push -u origin main?pushes the code to GitHub.

The?-u?flag creates a tracking reference for the branch, and?origin main?puts the code in the?main?branch.


Those are some of the main commands you'll use all the time. This is a beginner and non-technical guide to help you get started using Git and GitHub, so we won't go into too much more detail here.

The more you continue using GitHub, the more comfortable you'll get using these commands. The key is to start small and maintain your momentum.

It will eventually get easier as you build small projects and host them on GitHub using Git.

If you find it hard to use the terminal to navigate between folders, spend some time to practice with it. Again, it gets easier with time and use.

How to Customize Your GitHub Profile

Customizing your GitHub profile README helps you stand out from random GitHub users.

The README.md file helps you describe your GitHub profile, and you can use it to show what you're currently learning along with your skills and contributions.

The GitHub README.md uses markdown to format its content. It has an easy-to-learn syntax.

Here?is a simple guide to create and customize your GitHub account.

Here is my GitHub profile's README.md file.

You can check out some other GitHub README.md personalized profiles?here.


Resources to learn Git and GitHub

Here are some helpful courses and articles you can go through if you want to learn Git and GitHub in more detail:

  1. Git and GitHub Tutorial – Version Control for Beginners
  2. Basic Git Commands – How to Use Git in a Real Project
  3. Git and GitHub for Beginners - Crash Course
  4. An introduction to Git: what it is, and how to use it
  5. About GitHub


Conclusion

If you have finished reading this, you might be feeling overwhelmed about Git and GitHub. Yes it's another big thing you need to learn in tech, but do not fret.

Remember that whenever you start learning something new, at first it can seem like you won't get the hang of it. But after some time and hard work, you'll become more comfortable.

It's the same with Git and GitHub too – if you use it a lot for a while, you will get comfortable with it.

Thanks for reading this article. If you enjoyed it, consider sharing it to help other developers.

This is a tutoriel that i found this guide to use Git and Github :

https://www.freecodecamp.org/news/introduction-to-git-and-github/

Happy Learning.

要查看或添加评论,请登录

Montassar kefi的更多文章

  • Git and Github Datasheet

    Git and Github Datasheet

    What is Git : ? Git is a version control system. ? Git helps you keep track of code changes.

  • GitHub Command

    GitHub Command

    Ligne de commande principale Rappel Ne pas oublier : l'aide en ligne de commande. git help config git help push git…

    1 条评论
  • Spring Boot

    Spring Boot

    ma?trisez la mise en oeuvre d’une application web (Spring MVC) implicant un accès données via JPA (Spring Data) et un…

  • Construisez des microservices

    Construisez des microservices

    Si vous êtes amenés à travailler sur une application développée autour de l'architecture Microservices en Java, vous…

  • Sécurité : comment installer une double authentification ?

    Sécurité : comment installer une double authentification ?

    La double authentification, parfois appelée vérification en deux étapes ou authentification à deux facteurs, est un…

社区洞察

其他会员也浏览了