Git and GitHub - Using Git the right way to maximize your work
Git and Github are two very familiar concepts to developers, in fact many people use them every day. So what do you need to know specifically about Git and GitHub? How to use them correctly from the beginning to work effectively later?
Git and Github Basics
Let's consider a story about two programmers working on a project together:
There are two programmers who are working together to build a software for a client. And these two guys choose to work together by each writing a little code and sending it to each other via email or some other common data transfer method. After receiving each other's code, each person will review and edit it, then work together to assemble the software they need to do. However, one day, Mr. A accidentally wrote the wrong code into the software, leading to a faulty product that neither of them had backed up before because the software was too large. And so the two guys worked together to rebuild the faulty feature and continued to send it to each other like that.
From the above story we see two problems arising here:
1. Each person codes their own code and sends it to each other via email, which is very time-consuming. Furthermore, Mr. B will not be able to know what Mr. A has changed, whether it affects the general code of the entire system or not, and merging code is very difficult to control.
2. Modifying code without a previous backup makes them have to rewrite the code from scratch when the software fails. The appearance of Git will help solve the problem of the two guys above quickly, in addition, Git has many other useful features.
So what is Git and what is it used for?
Git is the name of a Distributed Version Control System ( DVCS ), one of the most popular distributed version control systems today.
DVCS means that each computer can store many different versions of a source code cloned from a source code repository, each change to the source code on the computer can be committed and then uploaded to the server where the main repository is located. And another computer (if they have access) can also clone the source code from the repository or clone a set of the latest changes on the other computer.
In Git, the working directory on your computer is called the Working Tree.
Simply put, Git will help users save versions of changes to the source code and it will be easy to restore without having to manually copy and paste somewhere, that version has been backed up. When we discover an error somewhere and want to backup the working session before the error occurs, it will be very simple when we use Git. Another special feature is that a member of the same team when working together can completely track online the changes of other members in each working version without having to sit next to each other, they can also compare those changes and then merge the other member's version into their version. Finally, everyone can put changes to their source code into a source code repository.
Git's versioning mechanism is that it will create a "snapshot" of each file and folder after committing, from which it can allow you to reuse a snapshot that you can understand as a version. This is also the advantage of Git compared to other DVCS when it does not "hard save" data but will save it in snapshot form.
And who is that half-brother?
Github Overview
We have heard of Git and may have used GitHub, but most of us still confuse Git vs GitHub because when we talk about Git, we think of GitHub. That is a misunderstanding because Git, as explained above, is the name of a system model, computers can clone source code from a repository, and GitHub is the name of a company that provides public repository server services, each person can access the homepage website to create an account on it and create their own source repository when working.
Github is highly appreciated and preferred, many big companies put their code repository here: Twitter, Facebook, linkedin. and google is also present on Github.
Home: https://github.com/
Install Git on Linux
Use without encryption
Step 1 : Install Git
Step 2 : Set up Git user information:
Step 3 : Check the information again:
SSH encrypted link
Generate private key:
=> Remember the created passphrase .
Result after creating key:
Add private key to SSH process:
Copy public key
Go to URL: https://github.com/settings/keys , select New SSH key:
Paste the public key and select Add SSH key:
Re-authenticate your Github password:
Link successful, can commit to Github on local machine without entering username and password.
Git Operations
Clone
Allows cloning of repository from Github to local machine
or
Add
While working with Local Repository , create newfile.md file in /root/INTERN/docs path
Add file to Github:
git add newfile.md
or add all added files:
git add *
Test: newfile.md file is waiting for commit
git status
Commit
Like a final review of changes in the local repository to push to Github
git commit newfile.md -m "Create new file"
or commit all pending files:
git commit -m "Create new file"
-m: Record comments for a commit
Push
Push committed files to Github
git push origin master
Pull
Suppose there is a change made on Github, which needs to be synchronized to Local to work. The pull operation will compare the remote repo on Github and the Local repo, then synchronize to the Local machine.
git pull
In addition to Git and GitHub, there is also GitLab source code management and is now available on TipsMake's Prebuilt App. Users can integrate up to 50 other convenient working tools with just a few clicks at: https://bizflycloud.vn/prebuilt-app/apps
According to TipsMake
You should read it
- How to turn off Facebook Platform to stop sharing personal data
- 6 powerful features of Google Analytics
- Effective call recording applications on smartphones
- Watch Sony Vaio S new generation
- Installing Internet at home: Optical cable or copper cable?
- Track changes in sensitive security in Windows
- How to turn off spell checking in Word
- How to Import PST Files to Office 365
May be interested
- GitHub Models launches, allowing developers to find and test AI models for freegithub has officially announced github models, a new service that allows developers to find and test ai models for free.
- How to Use Deploy Keys on Github'deploy keys' in github allow your server to connect directly to your github repository. when your server is connected, you can push builds directly from your repository to your server, which can cut down on your work. if your server needs...
- How to Download a GitHub Folderthis wikihow teaches you how to download a github folder by downloading an entire repository. github allows you to download a repo locally to your computer with just a few simple steps. please note that downloading a specific folder from...
- 82% of code on GitHub is copying existing filesthat's the result of a recent study by researchers from the university of california, irvine, microsoft research, czech technical and northeastern.
- GitHub is under strong phishing attack, users pay attention to account securitygithub - the world's largest open source software repository, is now the target of a phishing attack campaign.
- GitHub Copilot is now available for free in VS Codegithub, the most popular platform for the global developer community, has officially surpassed 150 million members.
- GitHub's machine learning tool can detect vulnerabilities in codegithub's tool will help eliminate common security holes before the code is put into the final stage.
- GitHub free all features for usersdevelopers can use all the core features of github without paying for it.
- GitHub launches 'Copilot', an AI that can code with yougithub has just officially launched a new ai programming tool called copilot. this tool will accompany programmers and developers to help them create more quality code in a variety of programming languages such as python, javascript, typescript, ruby and go.
- GitHub bury its entire repository under the North Pole to prevent the apocalypse happeninggithub's data block will be continuously stored in many formats and buried in different locations on earth.