Learn how to use Git and GitHub. Learn how Git and GitHub work. What are Git and GitHub? Why should you learn Git and GitHub? Differences between Git and GitHub. How to start using Git and GitHub. Resources to learn Git and GitHub
Git and GitHub are common tools used in programming. They help you manage different versions of your code and collaborate with other developers.
Building projects is one of the core parts of being a developer. And Git and GitHub are essential tools you'll use when building projects with others.
But they can look complicated if you haven't used them before. So I wrote this article to simplify how Git and GitHub work.
Git was developed in 2005 by Linus Torvalds as open source software for tracking changes in a distributed version control system.
Git is open source because its source code is made freely available for anyone to modify and use, aside from its creator. Open-source projects are built and maintained collectively by different developers in different locations.
Git track changes via a distributed version control system. This means that Git can track the state of different versions of your projects while you're developing them. It is distributed because you can access your code files from another computer – and so can other developers.
When you're building an open source project, you'll need a way to document or track your code. This helps make your work organized, and lets you keep track of the changes you've made. This is what Git lets you do.
But you also need a place to host your code – which makes controlling each version of your project easier and faster. This is where GitHub comes in.
GitHub is a "hub" (a place or platform) where Git users build software together. GitHub is also an hosting provider and version control platform you can use to collaborate on open source projects and share files. When you're using GitHub, you're working with Git beneath the hood.
According to Techmonitor.ai, over 73 million developers use GitHub as of November 2021. And the GitHub community is set to hit 100 million users by 2025.
As you can see, millions of people all over the world use these tools, and the numbers just keep going up.
Because of this, more companies are requiring new hires to know how to use Git and GitHub. So if you're looking for a developer job, these are essential skills to have.
If you're not using Git and GitHub, it's clear – you should be!
Git is a version control system that manages and keeps track of your code. GitHub, on the other hand, is a service that let you host, share, and manage your code files on the internet.
GitHub uses Git underneath, and lets you manage your Git repositories or folders easily on its platform.
So Git is the actual version control system and GitHub is the platform where you host your code.
If you want to learn more about the differences between these two tools, you can read this tutorial.
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 and then select your operating system to 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.
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 GitHub.com here.
You'll do this from your terminal.
To set your Git username, type this in your terminal:
git config --global user.name "Segun Ajibola"
To confirm that you have set your Git username correctly, type this:
git config --global user.name
You should have "Segun Ajibola" as the output.
To set your Git email, type this in your terminal:
git config --global user.email "firstname.lastname@example.org"
To confirm that you have set your Git email correctly, type this:
git config --global user.email
You should have "email@example.com" as the output.
You will be asked to authenticate your GitHub account, so just sign in with the same email to confirm.
Click the + sign at the top right corner to create a new repository. Repositories are like your code folders online.
You will be prompted to this page:
Name your repository and give it a description (this is optional).
Click the "Create repository" button to create the repository. You will be prompted to this page:
You can use the code editor built-in terminal to use Git to push your code to GitHub. Click
' to open the terminal in VSCode.
Input the commands below one after the other in your terminal. Press the
Enter key to proceed after every input.
echo "# sample-code" >> README.md
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/segunajibola/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/segunajibola/sample-code.git will contain the link to your own repository and it will have have the name of your GitHub account.
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.
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
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
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.
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.
Here are some helpful courses and articles you can go through if you want to learn Git and GitHub in more detail:
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.
Original article source at https://www.freecodecamp.org
There is no doubt that Git plays a significant role in software development. It allows developers to work on the same code base at the same time. Still, developers struggle for code quality. Why? They fail to follow git best practices. In this post, I will explain seven core best practices of Git and a Bonus Section.
Committing something to Git means that you have changed your code and want to save these changes as a new trusted version.
Version control systems will not limit you in how you commit your code.
But is it good? Not quite.
When you do an atomic commit, you’re committing only one change. It might be across multiple files, but it’s one single change.
Many developers make some changes, then commit, then push. And I have seen many repositories with unwanted files like dll, pdf, etc.
You can ask two questions to yourself, before check-in your code into the repository
You can simply use the .gitignore file to avoid unwanted files in the repository. If you are working on more then one repo, it’s easy to use a global .gitignore file (without adding or pushing). And .gitignore file adds clarity and helps you to keep your code clean. What you can commit, and it will automatically ignore the unwanted files like autogenerated files like .dll and .class, etc.
#git basics #git command #git ignore #git best practices #git tutorial for beginners #git tutorials
IT is in no way different from any other sector when it comes to naming. You would see some systems being named based on their origin while others are named keeping in mind their features or functionality. Then there are some whose names have nothing in common with their origin, features, or anything else related to them.
It is these inconsistencies in naming conventions that make people confused about what a system is all about, what it does, and what benefits it offers. For instance, there are a lot of people out there who still get puzzled when asked about Git and GitHub and whether or not there is a difference between the two.
The similarity in their names has nothing to do with what they really are. They are two altogether different things. But at the same time, you can say that they still have a thing or two in common. Before we talk about Git and GitHub, let us first shed some light on version control systems (VCSs) and why are they so important.
In simple terms, version control is nothing but a system that keeps track of the changes made to source code or files. With a version control system, you can look back at the changes made to a particular file, either by you or another person, by accessing the version control database. This system gives you the ability to compare different versions of a file, thus allowing you to stay informed about the changes that have happened over a period of time.
The version control system can be referred to as a database that stores snapshots of different files in a project. These snapshots are taken every time a file is modified. It maintains all the records of the different versions of a file. In addition to comparing different versions of a file, VCSs also allows you to switch between them. VCSs can either be distributed or centralized. Let us see how these two types differ.
Centralized version control systems use a single, centralized server to store all the different versions of a file. Users can access these files by gaining access to this centralized server. Now, there is a disadvantage associated with this type of VCS. If the central server fails to function due to any reason, the entire history stored on its will be gone and no one will be able to recover any version/versions of the lost files.
Distributed version control systems have an edge over their centralized counterparts. These VCSs store file versions in two locations – the centralized server and your local machine. So, the disadvantage that we discussed centralized systems doesn’t exist in distributed systems.
Even if the server undergoes failure, you can retrieve all the different versions of your files from your local machine. Suppose you have a file, which is called VersionControl1. Now you made several changes to this file and saved the changes on each occasion. All the changes that you made to this file will be stored in the VCS, which will have all those versions of this file when you made changes to it.
#full stack development #git vs github #git #github
Git has become ubiquitous as the preferred version control system (VCS) used by developers. Using Git adds immense value especially for engineering teams where several developers work together since it becomes critical to have a system of integrating everyone’s code reliably.
But with every powerful tool, especially one that involves collaboration with others, it is better to establish conventions to follow lest we shoot ourselves in the foot.
At DeepSource, we’ve put together some guiding principles for our own team that make working with a VCS like Git easier. Here are 5 simple rules you can follow:
Oftentimes programmers working on something get sidetracked into doing too many things when working on one particular thing — like when you are trying to fix one particular bug and you spot another one, and you can’t resist the urge to fix that as well. And another one. Soon, it snowballs and you end up with so many changes all going together in one commit.
This is problematic, and it is better to keep commits as small and focused as possible for many reasons, including:
Additionally, it helps you mentally parse changes you’ve made using
#open source #git #git basics #git tools #git best practices #git tutorials #git commit
Hello all, nowadays most of the development teams using GIT version control, some of you may have a requirement of mirroring your team’s git changes from one server to another Git server. This article will help you to achieve the Git mirroring between one server to another server.
I got one assignment wherein there will be 2 Git Servers, development will happen in one Git server and the changes should be synchronized to another Git server at regular intervals. But in my case, the complexity is both the servers are in different restricted network. So I have done the small experiment and it worked. And I am sharing the steps to you all in this article.
Main GIT Server: Let’s take our main git server is located in our office and can be accessed only in-office network.
**Mirror GIT Server: **The mirror server is located at the vendor/client-side, which can be accessible in a normal internet connection but not with our office network. Since the office proxy will block the outside URL’s.
#devops #git #git and github #git best practices #git cloning #git server
In this part you will get familiar with some basic Git commands. At the end of this blog you will be able to perform certain task like
These are those commands you must conquer
<!DOCTYPE html> <html> <head></head> <body> <h1>Sab Batade Aapko</h1> </body> </html>
Initializing the folder as a Git repository
this command will make a file named .git
#github #git #basic-git-commands #git-commands #git-status