You need git for your files.

I have come to git again to pull the shit, pull the shit, or git is the best, it seems yes.

What is Git? I just began to enter the time also do not know what is, just heard that programmers can not do without this artifact tool every day.

Git is the most advanced distributed version control system in the world.

What is multi-version control? It’s a convenient example

For example, if you use Word or any other writing tool, you’ve probably experienced this:

  • At the beginning, WHEN I finish writing, I often want to delete a paragraph, but I am worried that I can not find it in the future. So, I’ll just copy the current file to a new Word file or something else, and then I’ll change it to a certain point, and you’ll find that you have a lot of files in your folder, and I’ll say, “This is a bit messy.” Manual funny…
  • Moreover, in terms of coordination, for example, two people write some documents separately. If the documents are frequently changed, there will be a big problem when merging them. If there is a tool or software that can record every change in the files, wouldn’t it be easy to understand it by glancing at the software? Isn’t it convenient?

Isn’t this software Git? Install Git on three platforms and serve it directly

windows

  1. website
  2. Download and install
  3. Terminal testgit --version

Linux

  1. sudo apt-get install gitNote: This is Ubuntu
  2. yum install gitNote: this is centos
  3. Terminal testgit --version

mac

  1. MAC comes with
  2. Available Terminal Viewwhere git

I have used the MAC for many years. Here is a picture of the MAC:

Github, by the way

Is there anyone who doesn’t know what Github is?

The world recognized code repository, the stain, the words are said to this member, I have to mention my Github, hee hee.

Come on, github.com/DreamCats

Come on, I’m crazy. I put a picture on the AD

Okay, you’re shameless. Don’t panic. Get started

Official website: Link

Go to the official website and click Sign Up in the upper right corner

  1. Username: Your Github name can also be used as a login account
  2. Email address: your Email address can also be used as a login account
  3. Password: indicates the login Password
  4. Email Preferences: What social information can be notified by Email
  5. Verify your account: Verify your account.

After registration, the login page

  1. You can see your avatar in the upper right corner, click on it and there’s a menu bar
  2. As shown in the image above, there is your profile page, your repository, etc., and your Settings below
  3. You can change your avatar, name, SSH key, etc

associated

Associated? What I really mean is to associate your local Git repository with your Github repository

Before associating Git, say a few words about configuration file stuffing

  • /etc/gitconfigFile: A configuration on the system that is universally applicable to all users. Git config--systemOption, read and write to this file;
  • ~/.gitconfigFile: The configuration file in the user directory applies only to the user. Git config--globalOption, read and write to this file;
  • Configuration files in the current project’s Git directory (that is, in the working directory).git/configFile) : The configuration here is valid only for the current project. Each level of configuration overrides the same configuration on top, so.git/configThe configuration in/etc/gitconfigVariable with the same name in;

Configuring User Information

The first thing you need to do when installing Git is set up your username and email address. These two configurations are important because they are referenced every time Git commits, indicating who committed the update.

git config --global user.name "DreamCats"
git config --global user.email "[email protected]"
Copy the code

If you want to use a different name or E-mail address for a particular project, you can run this command in that project instead of the –global option. You can also go to.git/config for your local project

Check the configuration

If you want to see your own configuration, use the git config command. ->global->local ->global->local -> system->global->local ->global->local You can locate the configuration file.

git config --system --list    Check the system configuration
git config --global --list    Check the current user configuration
git config --local --list     Check the current warehouse configuration
git config --list             # check all configurations
Copy the code

Single user association

Terminal input:

ssh-keygen -t rsa -C "[email protected]"
Copy the code

The SSH key can be generated after three sessions

At this point, you should pay attention to a few files and then perform the corresponding actions

  1. MAC or Linux: Yes~/.sshfindid_rsa.pubfile
  2. Win:c:\Users\Administrator\.sshfindid_rsa.pubfile
  3. When open, copy one of the strings
  4. Go to Github, open Settings and look for SSH and GPG keys
  5. Then enter it at the terminalssh -T [email protected]
  6. The terminal will outputHi DreamCats! You've successfully authenticated, but GITHUB.COM does not provide shell access.

Multi-user association

When you have multiple Git accounts, for example:

  • A GitLab for in-house work development;
  • A Github for doing some development on your own
  1. Generate shh-keys for each Git account separately
ssh-keygen -t rsa -C '[email protected]' -f ~/.ssh/gitlab_id_rsa
ssh-keygen -t rsa -C '[email protected]' -f ~/.ssh/github_id_rsa
Copy the code
  1. In the ~/. SSH directory, create a config file and add the following contents: Host and HostName specifies the git server domain name, and IdentityFile specifies the path to the private key.
# gitlab
Host gitlab.com
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab_id_rsa
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa
Copy the code
  1. Use SSH command to test respectively, the premise is to paste the file pub into the corresponding Gitlab or Github account under the SSH key, prompt: Github and Gitlab Settings bar has
ssh -T [email protected]
ssh -T [email protected]
Copy the code
  1. The results are as follows
Hi DreamCats! You've successfully authenticated, but GITEE.COM does not provide shell access.
Hi DreamCats! You've successfully authenticated, but GITHUB.COM does not provide shell access.
Copy the code

Note: Change the address of push, by default, to the contents of the config file under the.git directory of our project

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = true

[user]
	email = [email protected]
	name = Dreamcats
[remote "origin"]
	url = [email protected]:DreamCats/JavaBooks.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
Copy the code

Now push is fine

github-page

Maybe everyone wants to write a blog, but they don’t want to buy a server to make their blog accessible anywhere, so github page comes…

create

Official website: official website registration, I lost, no content? Why write it again

  1. Create a new repository on the home page

  1. Only one github. IO can be created per account as shown in the image above
  2. Note the user name and initialize the README
  3. You can access it at this pointhttps://dreamcats.github.io/

End and spend

You think it’s over? How is that possible? I still have my heart? I want to share more with you…

Git installation and use is basically no problem, so we should learn its command briefly? You can’t just listen to it and not use it. Is a gentleman good at faking things?

To double your productivity, consider which tools offer the best value for money: the cost of learning, the revenue generated, a chore like brushing your teeth

Don’t panic. I will share with you some common commands for git development.