Git basics in Linux

Source: Internet
Author: User
Tags using git hosting website
1. compared with CVS and SVN, the git version control system supports offline development and offline Repository-powerful branch functions and is suitable for collaboration among multiple independent developers-speed block ps: the more detailed introduction of git is not described here. it is critical to teach you how to use it. :)... 1. git version control system
 
Advantages over CVS/SVN:
 
-Supports offline development and offline Repository
-Powerful branch functions, suitable for collaboration between multiple independent developers
-Speed block
 
Ps: For more details about the advantages of git, I will not introduce it here. it is critical to teach you how to use it. :)
 
================== Running environment ========
 
System: windows
 
Git: Git-1.7.3.1-preview20101002.rar: http://d.download.csdn.net/down/3169511/z_y_liu89
 
======================================
 
 
 
2. github is a git project hosting website
 
Registered Address: https://github.com/signup/free
 
 
 
3. install the git program and perform the following operations:
 
$ Cd ~ //. Ssh // Check the ssh key of the computer
If No prompt is displayed: No such file or directory indicates that you are not using git for the first time. perform the following operations to clear the original ssh key.
 
$ Ls
Config id_rsa id_rsa.pub known_hosts
$ Mkdir key_backup
$ Cp id_rsa * key_backup
$ Rm id_rsa *
Copy code
Get Key:
 
Ssh-keygen-t rsa-C "defnngj@gmail.com" // enter the email address and press enter until OK
Open the local file .. \. ssh \ id_rsa.pub. This file contains the adult key generated just now.
 
4. log on to the github system. Click Account Settings ---> SSH Public keys ---> add another public keys
 
Copy the locally generated key to it (in the key text box) and click add key.
 
5. open git and test whether the connection is successful.
 
$ Ssh-T git@github.com
Note: Hi defnngj You 've successfully authenticated, but GitHub does not provide shell access.
 
6. set user information:
 
6.1
 
$ Git config -- global user. name "defnngj" // give yourself a username $ git config -- global user. email "defnngj@gmail.com" // enter your mailbox
Copy code
6.2
 
Find the Account Settings ---> Account Admin in github and find the information:
 
Your API token is e97279836f0d424a3954c1193dba522f --- keep it secret! Changing your password will
 
Generate a new token
 
$ Git config -- global github. user defnngj // username on github $ git config -- global github. token e97279836f0d=a3954c1193dba522f
Copy code
 
 
============================== Create a project ========
 
1. return to the github homepage and click "New Repository" in the lower right corner of the page"
 
Enter the Project Information:
 
Project name: hello world
 
Description: my first project
 
Click "Create Repository". Now a project is created on github.
 
2. we need to use git to create an identical project locally.
 
$ Makdir ~ /Hello-world // create a project hello-world $ cd ~ /Hello-world // open this project $ git init // initialize $ touch README
$ Git add README // update the README file $ git commit-m 'first commit '// submit the update and comment out the information "first commit" $ git remote add origin git@github.com: defnngj/hello-world.git // connect to remote github project $ git push-u origin master // update local project to github project
Copy code
Check the hello world project on github to see if the local README file has been updated. :) Congratulations!
 
 
 
------------------------------------ Possible errors ----------------------------------
 
1. execute
 
$ Git remote addorigin: git@github.com: defnngj/hello-world.git
 
Error message: fatal: remote origin already exists.
 
Solution:
 
$ Git remote rm origin
 
Then, when you execute: $ git remote add origin git@github.com: defnngj/hello-world.git, no error will be reported.
 
 
 
2. execute
 
$ Git push origin master
 
Error message: error: failed to push som refs .......
 
Solution:
 
$ Git pull origin master // first pull the files on the remote server github and then push them.
 
 
 
--------------------------- Postscript -----------------------------------------------------------------------
 
This article is to refer to the official help: http://help.github.com/win-set-up-git/ is basically the same as the official steps, I am here to translate it!
 
For more information, visit http://progit.org/book/zh/to learn more.

Author: bluishoul's blog
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.