Introduction to GIT
Co-Author: Y. S. Huang, a master’s student studying AIVC, likes open-source.
If you are interested, go to check my Github!
What is GIT?
Git is a distributed version control system. It allows you to track the changes made to files. The git
command will track the file you changed after you use add
to track it. You also can save some information you want to record by using commit
, and check want you recorded in the previous by using log
. Some day, you want to go back to any specific version you need, the checkout
is the command that you need at the first. which means that you don’t need to worry about the steps you take that will disable the overall functions.
Git also provides a user-friendly function that makes collaboration between engineers more efficient. It allows engineers to work in different branches. The branches don’t affect one another. Once the branch function works accurately, we can merge it into the file.
Distributed version control system
A distributed version control system (DVCS) is a type of version control where the complete codebase including its full version history is mirrored on every developer’s computer. And Changes to files are tracked between computers.
Git has a remote repository stored in a server and a local repository stored in the computer of each developer. This means that the code is copied in all the developer’s computers.
The advantages of a Distributed version control system
- Reliable backup copies
- Fast merging and flexible branching
- Rapid feedback and fewer merge conflicts
- Flexibility to work offline
How does Git record?
Instead of recording changes like other version control systems do, Git stores data as a series of snapshots over time. It makes git more like a mini file system.
Git does not automatically save every change you make. You can use some commands to tell Git which changes you want to save.
Git commit records:
Author
Time
Content
Reason
How to use git
There has a simple example for you:
After downloading Git, open a terminal to start.
- type
git init
to create a git repository. - create a test file.
- type
git status
and you can see that the test.txt file is untracked. - type
git add test.txt
and then typegit status
. You will see that the file is to be committed.
git commit
saves the file into the Git repository. And you are required to describe the file.git log
will show the history of the files.
Basic Git Commands
Here are some basic Git commands to use in Terminal.
Git checkout
: Switch from one branch to another.Git status
: To get information about the current branch.Git add
: When we create, delete or change a file, we need to use git add to include the changes into the next commit.Git commit
: Once you finish a certain point in development, you can use git commit to save the changes.Git log
: To review the history of everything that happens to a repository.git init
Initiate a git repository in the folder.