This is the second day of my participation in Gwen Challenge
preface
This article was written in a Debian/Linux environment.
Git is indispensable in daily work, so I write this article to teach you how to use Git for future work and study.
At the same time, this article has accumulated some Git skills that many bloggers use in their work and development, including their daily development. At the end of this article, a common command table about Git has been sorted out.
Git commands are numerous, but only a dozen are commonly used.
Writing is not easy, like you can focus on praise three, thank you!
The development process
Git was originally written by Linus, a Linux developer, in pure C language in just two weeks. After writing Git, he immediately took over the Linux source code. Before that, Linux was managed by BitKeeper, a distributed version control system developed by BitMover. BitMover licensed it to the Linux community for free. In 2002, Linux began using the BitKeeper distributed version control system to manage source code, but it didn’t last long. One day Linux community member Andrew (author of Samba (C/S program for LAN shared files) tried to crack BitKeeper for everyone to use. BitMover found out and took back the copyright for free use. Linus then developed Git in two weeks (two weeks including testing), which is by far the best distributed version control system available.
Github and Git are two things, github is a community, Git is a service system, github only supports Git distributed system, so the name is github.
In addition to Git, there are other version control systems such as SVN and CVS. The difference between them is that one is distributed and the other is centralized
Centralized is the SVN and CSV version control system, distributed is Git
Difference is that a centralized version control system when writing code every time need to pull a down from the server, and if the server is lost, then all is lost, you native client only to save the current version of the information, in other words, the centralized centralized management is to put the code on a server, you need all the rollback operations such as server support.
Distributed difference is that everyone is the server computer, when you’re a code from the main warehouse pull down, your computer is the server, without having to worry about the warehouse floor or can’t find the information, you can freely in the local rollback, submit, when you want to submit your own code to the main warehouse, only need to merge to push to the main warehouse is ok, You can also create a repository of your code and share it with others.
Like centralized they all have one major version number, all versions of the iteration is given priority to with the version number, and distributed for each client is the server, git has no fixed version number, but there is a hash algorithm to calculate the id, using rolling back and forth, at the same time also has a master warehouse, the warehouse is the master of all branch warehouse storage, We can push commit to master and merge to master repository. The master repository version number will iterate once. No matter how many iterations of git version number on our client, master will iterate once only when merge.
Debian/Linux install Git
Sudo apt install git
sudo apt search git
Copy the code
Git config –global
The config: parameter is used to configure the Git environment
–global: long command to configure the entire Git environment
If you are using git for the first time, you will need to set up your username and email address. This will be used as the identification of git on your current machine. If you use git to download remote repositories, some repositories that require login permission will require login
User Name Configuration
User indicates the user, and. Name indicates the name of the configuration user
Git config --global user.name git config --global user.nameCopy the code
Email configuration
User indicates the user, and. Email indicates the email address of the user
Git config --global user.emailCopy the code
Do not configure the line, when the remote warehouse will let you manually enter the user name, email, and password
Git init init: Initializes the current directory as the repository. After the initialization, the repository is automatically set to master
To create a local repository, you need an empty directory and then initialize your project in the empty directory
Let’s say I want to create an empty project named “test”
1. Create a directory
mkdir test
Copy the code
2. Access the directory
cd test
Copy the code
3. Initialize the current repository with git init
git init
Copy the code
After initialization, git configuration file directory will be generated. Ordinary “ls” command is not visible, we need to use ls -ah to view the hidden directory, you can see its related configuration file after entering the directory