Article Directory
A. Git Profile
Recently started using Git to manage your own code, here summed up some knowledge about GIt aspects of what I've learned how to use the git in a Linux environment.
1.git generation history
git is the world's most advanced distributed version control system, is commonly used in the development of our project code management tools.
Refer to relevant historical git origin history
2.git features
(1) Version Control:
Can solve the problem over the same time developing the code, you can also solve the problem of history back code;
(2) Distributed
GIt is a distributed version control system, with a Git repository, it can be distributed to different machines.
Two. GIt installation
1. Install command
Enter the command in the Linux environment:
sudo APT-GET install git
If the selected y / n appears, choose y. Then Qiaoxia git command, if a bunch of commands appears, the computer has been installed git.
2. Create a version of the warehouse
(1) Create a new directory git_test, create a repository in the directory, the following command:
git the init
After this, use ls -al command, you can see hidden files in a .git.
After git help of this document will help you manage code.
III. Creating version
Git_test code written in the directory, using
git add file name code is pushed into the staging area;
use
'description of some of the versions (e.g.: Version 1)' git commit -m
generates a version Thereafter,
git log view; the effect is as follows:
About version rollback and work area, staging area in repository relationship with the commands, refer to version rollback districts relationships with git (important)
IV. Cloud code push Github
1. Log in to the website Git official website
Register your account.
2. Create a warehouse
After
clicking to create their own warehouses can generate up.
3. Generate ssh key
(1) to return to their Linux client, return to edit the file in your home directory ,, .gitconfig, fill in your own mailbox used for registration, save and exit, execute the command
ssh-keygen -t rsa -C 'mailboxes registered'
The system will have three tips, respectively enter or enter y to. After the success of the following
(2) cd .ssh / into the directory, copy the contents of id_rsa.pub, this is your public key!
4. Add ssh account.
We need to set your Linux ssh client accounts and clouds binding warehouse before they can be pushed to the cloud own code repository! Click on the top right icon, select "settings"
select SSH and GPG keys
first column name easily take the assistance of the public just pasted in the second column, click on the ADD SSH key!
Item 5. Cloning
(1). Copy the URL.
(2) back to your home directory execute the command
git clone just copied the contents of
cloning is successful, there will be one and the same with your user name folder, cd to enter.
6. Push Drive and fetch the code.
(1) execute git branch see the branch, the branch will see a master, we usually do not write code at this branch, you need to create a new branch, the following command:
git Checkout -b branch name
I get called smart, then get executed again branch below
so you can write code!
(2) after the code is written using three command
git add filename
git commit -m 'descriptive information'
Git Push branch name Origin (Smart)
And then in the official website Github repository, click on the branch
you can view your code it! !
(3)
using the command
git pull branch name can be pulled from the cloud of the code.