Simple use of Git

Source: Internet
Author: User
Tags git client version control system

I used SVN before, but recently I found that git features are much better than SVN. So I want to configure git, but each download to half will fail (possibly due to network reasons), and finally I will throw it to one side. I tried it again yesterday and it succeeded. Today I will simply sort it out and send it here.

1. Git introduces git as an open-source distributed version control system for efficient and high-speed processing of project version management from very small to very large. Git is an open-source version control software developed by Linus Torvalds to help manage Linux kernel development. Torvalds started to develop git to replace bitkeeper as a transitional solution, which has been a major source code tool used by Linux kernel developers worldwide. Some people in the open source community feel that bitkeeper licenses are not suitable for the open source community, so Torvalds decided to study a more flexible version control system for licenses. Although git was initially developed to assist in Linux kernel development, we have found that git is also used in many other free software projects. For example, it has recently been migrated to git, and many freedesktop projects have also been migrated to git.

Save point: the GIT save point can track files in the source code and get the status of the entire project at a certain point in time. You can merge the source code submitted by multiple users at this save point, it can also be returned to a storage point;

Git offline Operability: git can submit code offline, so it can be called completely distributed processing, and all git operations do not need to be done online; this means that git is much faster than SVN and other tools, because SVN and other tools need to be operated online. If the network environment is poor, code submission will become very slow;

Git snapshot-based: old version control tools such as SVN Save the submission point as a patch file, and git commit points to the project snapshot at the time of submission, the submitted items include metadata (author, date, GPG, etc );

Git branch and merge: The branch model is the most significant feature of git, because it changes the developer's development mode, and version control tools such as SVN place each branch in a different directory, git can switch different branches in the same directory;
Instant branch: the process of creating and switching branches is almost the same. You can upload some branches, and other branches can be hidden locally, without uploading all the branches to GitHub;

Branch flexibility: You can create, merge, and delete branches at any time. Multiple people can implement different functions. You can create multiple branches for development, and then merge branches. This method makes development fast and simple, security.

Git general client official: http://git-scm.com/、gitinstallation

You can use the default path for installation. For installation parameters detailed introduction, You can go here to see, which made a detailed introduction of http://www.ihref.com/read-16377.html

After the installation is complete, go to your installation directory and findGit Bash. vbs File. This file is required for configuration synchronization. Double-click to open the CLI console. Next, let's configure git.

  1. There are three transmission methods (for example) on git. Now let's chooseSSH Transmission. Enter ssh-keygen-t rsa-c "[email protected]" in the console.
    GitHub Email: the email address after this command is the registered email address of GitHub. (If you do not have an account, apply for it on GitHub first );
    Path Selection: After the command is run, a prompt is displayed, indicating to select the ssh-Key Generation path. Click Enter to generate the default path. The generated ssh-key is in the default path;
    Password confirmation: a self-set password. I will not use the password to log on here.
  2. Configure SSH to the GitHub website. Enter the generated SSH Directory: C: \ Documents ents and Settings \ Administrator \. SSH (or c: \ Users \ User Name \. SSH), use NotePad to open the id_rsa.pub file and copy the content of the file;
    Go to the GitHub Website: log on to GitHub and select setting for user settings:

    Find the SSH keys option in the list on the left:

    Then copy the SSH key value.

    Verify whether the configuration is successful:

    ssh -T [email protected]

    You may be asked to enter Yes during verification.

    Success prompt: If Hi cpacm appears! You 've successfully authenticated, but GitHub does not provide shell access. It indicates that the configuration is successful and you can connect to GitHub;

  3. Configure local mailbox

    User name email function: we need to set a user name and email address, which is used to upload the local repository to GitHub and display the code Uploader in GitHub;
    Run the following command:

    Git config -- global user. Name "cpacm" // set the user name git config -- global user. Email "[email protected]" // set the email address. Do not use the registered email address.

Install git now.

Iii. Use of Git
  1. Now we can find three new options in the right-click menu.
    The local repository is used to open the git gui and the GIT bash command console.
    First, weSelect a folder as the local repository

    Right-click the Directory and executegit init hereTo create a git repository.
    Use the LS command to view the files. For example, we have a test. Tet file in this directory, which can be used as follows:
    $ Ls 
    Test.txt

    You can also use CD to specify the address and make it warehouse

    $ CD path
    $ git init
    Initialized empty git repository in/opt/Konnichiwa/. Git/# Initialize an empty git repository in the/opt/Konnichiwa/. Git directory.

    Now you can see that there is.git. This is your git repository. All snapshot data about your project is stored here.
    In short, Usegit initTo create a git repository in the directory. You can do this at any time and in any directory, and it is completely localized.

  2. Clone a project to a local device

    If you need to work with another project, or want to copy a project and check the code, you can clone the project. Rungit clone [url], [Url] the project address you want to copy.

    $ git clone git://github.com/schacon/simplegit.git
  3. Add files to cache and upload
    After a repository is created locally, the right-click option changes.

    Item 1: add all files to the local cache; Item 2: Submit tool. If the local cache changes, the changes will be displayed.

    The third item is the submitted history, which is usually recorded once submitted. Item 4: git GUI management tools, such. Item 5: git branch. Item 6: console. Enter the description and Click Upload.
  4. Simple Flowchart

Iv. Git Client

Git has a dedicated client. If you install it, you don't need to implement the above.
Address: https://windows.github.com/

  1. GitHub Installation

    Basically, simply follow the steps (that is, the installation may fail, and I am stuck here for a long time ~).
    These two items are available after installation. Open GitHub and follow the prompts to set it.
  2. Settings page
    In the upper-left corner, a button for adding a project is displayed. in the upper-right corner, the setting button is displayed. Open the setting and select options.

  3. Add a project and clone a project

    I will not talk about the details at a glance. For clone, use shell to clone other open-source projects.
  4. Console

  5. Then I add a TXT file to the project, and the console changes in real time. At this time, we can submit the changes to the local cache.

  6. Branch
    Create and manage branches
  7. Delete a project
    The last one is to remove, but the file will still exist. The functions of other items are the same as those of the literal type.
    Delete a project on the GitHub website
    Go to the project you want to delete, and navigate to setting on the right.
    The project deletion button is displayed at the end of the jump.

The above is all I have installed git. I will put the project code on git in the future, so that I can familiarize myself with git as soon as possible.

 

References: (1) git version control software, combined with GitHub, provides a learning manual on getting started and mastering Common commandsHttp://www.ihref.com/read-16369.html

(2) GitHub for Windows use graphic tutorials http://www.cr173.com/html/15618_1.html

==========================================================

Cpacm

Address:Http://www.cnblogs.com/cpacm/p/3939008.html

Simple use of Git

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.