Git version control (i)

Source: Internet
Author: User
Tags version control system

? "declaration"

Welcome reprint, but please keep the original source of the article →_→

Life One number: http://www.cnblogs.com/smyhvae/

Article Source: http://www.cnblogs.com/smyhvae/p/3981720.html

Contact information: [Email protected]

Body

First, the initial knowledge of git:

Git is currently the world's most advanced distributed version control System (no one). Its developer is Linus Torvalds, author of the famous Linux operating system. Git was developed to better manage the Linux kernel and is now widely used in a variety of projects. Git quickly became the most popular distributed version control system, especially in 2008, when the GitHub site came online, providing free git storage for open-source projects, and countless open-source projects migrating to GitHub, including Jquery,php,ruby and more.

So what's the version control system? If there is a software, not only can automatically help me to record every time the file changes, but also allow colleagues to collaborate on editing, so that you do not have to manage a bunch of similar files, and do not need to pass the file. If you want to see a change, you just have to take a peek at the software, wouldn't it be convenient?

The software should look like this, recording changes to each file:

version User Description Date
1 Tom Removed software terms of service 5 7/12 10:38
2 Tom Increased the license number limit 7/12 18:09
3 John doe The financial department adjusted the contract amount 7/13 9:51
4 Tom Extend the free upgrade cycle 7/14 15:17

Second, install Git on the Linux platform:

First, you can try to enter Git to see if the system has git installed:

'gitinstall it by typing:install git   

If you are using Debian or Ubuntu Linux, you can complete the installation with one command:

Install Git

Note:

Older Debian or Ubuntu Linux, to change the command to "sudo apt-get install Git-core", because previously there was a software called git (GNU Interactive Tools), As a result, git can only call Git-core. Since git is so famous, it later changed GNU Interactive Tools to Gnuit,git-core to git.

If it is a different Linux version, you can install it directly from the source. First download the source code from the GIT website, then unzip, then enter:./config,make,sudo make install these commands are ready to be installed.

Third, install Git on the Windows platform:

When you want to use a lot of Linux/unix tools under Windows, you need to cygwin such a simulation environment, GIT is the same. Cygwin installation and configuration are more complex, not recommended toss. However, a man has already put the simulation environment and git are packaged, called Msysgit, only need to download a separate EXE installation program, and nothing else to install, absolutely good.

Msysgit is the Windows version of git, download link: http://msysgit.github.io/. When the download is complete, start the installation.

When installing, the following interface appears, by default:

The parameters are explained as follows:

    • Icon Component (addition icons): Choose whether to create a Quick Launch bar icon or whether to create a desktop shortcut;
    • Desktop Browsing (Windows Explorer integration): The way to browse the source code, a separate context browser only using bash or git GUI tools only; Advanced contextual browsing methods using the Git-cheetah plugin plugin;
    • Association profile: Whether to associate a git configuration file that mainly displays the style of the text editor;
    • Associated shell script file: whether to associate a script file executed by the bash command line;
    • Using TrueType encoding: whether to use Truthtype encoding at the command line, which is a generic encoding developed by Microsoft and Apple

Next, the following interface appears, by default:

Above picture, is set environment variable: choose what command line tool to use, normally we use Git bash by default, choose by default. The parameters are explained as follows:

    • Git comes with: git bash command-line tool with Git;
    • System comes with cmd: command-line tool using Windows system;
    • Both are: The above two are configured at the same time, but note that this will overwrite the Find.exe and Sort.exe tools in Windows, if you do not understand these try not to choose

Next, the following interface appears, by default:

    • Check out the conversion of Windows format to UNIX format: line wrapping in Windows format to UNIX format is committed;
    • Check out the original format to UNIX format: No matter what format, all into the UNIX format of the line to commit;
    • No format conversion: Do not convert, check out what, just commit what

To summarize, follow the default configuration to install it. After the installation is complete, find Git Bash in the Start menu , and a command-line window appears stating that the GIT installation was successful:


Second, various configurations:

(1) Configure identity:

After the installation is successful, you also need to configure the identity (that is, configure local Users and mailboxes), which is used to upload the local repository to GitHub and display the code uploader on GitHub. We enter the following command to configure:

"Your Name""[email protected]"

Because Git is a distributed version control system, every machine must be tell: your name and email address.

Note: The--global parameter of the git config command uses This parameter to indicate that all git repositories on this machine use this configuration, and of course you can specify a different user name and email address for a particular repository.

After the configuration is complete, you can use the same command to see if the configuration is successful, just remove the last name and email address.

(2) Set the default path for the GIT Local Project development library:

If you set it up, you don't have to open the directory every time you turn on Git and CD. Method: Right-click git shortcut icon (called: Git Bash), find the shortcut-start location, put your project address here. The default settings are as follows:

After modifications such as:

(3) Create a repository:

Repository also known as the Warehouse, English name repository, can be easily understood as a directory, the directory of all the files can be managed by git, each file modification, deletion, git can track, so that any time can track history, or at some point in the future can be "restored."

So, to create a repository is very simple, first of all, choose a suitable place, create a new empty directory, my new directory is: E:\codes\github\smyhvae, we first jump to this directory:

$ cd/e/codes/github/smyhvae

Note: The current directory can be displayed through the PWD command.

Then, use the git init command to turn this directory into a repository that git can manage:

In e:/codes/github/smyhvae/.git/

Instantly git has built the warehouse and tells you it's an empty repository (empty git repository), Careful readers can find that the current directory is more than a. Git directory (this is a hidden folder), this directory is git to track the management of the repository, do not manually modify the files in this directory, or change the mess, the Git repository to destroy.

Third, add the file to the repository:

Statement

First of all, it is clear that all version control systems, in fact, can only track changes in text files, such as txt files, Web pages, all the program code and so on, Git is no exception. The version control system can tell you every change, such as adding a word "Linux" to line 5th, and deleting a word "Windows" on line 8th. and picture, video these binary files, although can also be managed by version control system, but can't track file changes, only the binary files each change string up, that is, only know the picture changed from 100KB to 120KB, but what changed, version control system do not know, also can not know.

Unfortunately, Microsoft Word format is binary format, so the version control system is not able to track changes in Word files, the previous example is just to demonstrate that if you want to really use version control system, it is necessary to write the file in plain text.

Because the text is encoded, such as Chinese has a common GBK encoding, Japanese has SHIFT_JIS encoding, if there is no historical legacy issues, it is strongly recommended to use the standard UTF-8 encoding, all languages use the same encoding, no conflict, and supported by all platforms.

Children's shoes using Windows should pay special attention to:

Never edit any text file with a notepad that comes with Windows. The reason is that Microsoft Development Notepad team used a very mentally retarded behavior to save UTF-8 encoded files, they are smart to add 0XEFBBBF (hex) characters at the beginning of each file, you will encounter a lot of incredible problems, for example, the first line of the page may show a "?", obviously the correct procedure to compile a report on grammatical errors, and so on, are caused by the mentally retarded behavior of Notepad. Suggest you download notepad++ instead of Notepad, not only powerful, but also free! Remember to set the default encoding for notepad++ to UTF-8 without BOM:

Steps

Now we write a Readme.txt file in the E/codes/github/smyhvae directory and write something in it.

To enter the repository:

$ cd/e/codes/github/smyhvae

It only takes two steps to put a file into a git repository.

The first step: Use the command git add to tell git to add the file to the repository:

Update the local repository (. Refers to all current directories and files):

$ git Add.

Of course, if you just add a file, you can write this:

$ git Add readme.txt

Update a directory to write this:

$ git Add src/

In the second step, use the command git commit to tell Git to commit the file to the repository:

" Some instructions "[Master (root-commit) a2ebf86] Some instructions 2 insertions (+100644 readme.txt   

The git commit command, after-M, enters the description of the submission, andcan enter any content, but it's best to make sense, so you can easily find the record in the history.

Bother not to input-M "xxx" line? There are ways to do this, but it's strongly not recommended, because it's important for you to read to others.

When the git commit command succeeds, it tells you that 1 files have been changed (our newly added Readme.txt file), inserting two lines of content (Readme.txt has two lines of content).

Why does git add a file that requires add,commit two steps? Because commit can commit a lot of files at once, you can add different files multiple times, and then commit together at the end.

Common operations on the repository are explained in the next section.

This article refers to the link: http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

Category: Android Development Green channel: Good text to the top attention to my collection This article contact me life one number
Follow-65
Fans-261 + plus attention2 0(Please comment on the article) «Prev: Android series fragment (a)----fragment load into activity
» Next: Android series fragment (ii)----fragment life cycle and return stack posted @2014-09-19 16:16 Life One read (1174) Comment (7) Edit Collection


List of commentsReply Reference#1楼2014-09-20 00:15 BrisketSupport, yesterday in the use of git ignore files when there is a hole, ignoring the Chinese folder is OK, but the Ignore file is UTF-8 format of the line
Support (0) objection (0)Reply Reference#2楼2014-09-20 10:02 MinttangAnd so on, especially many people. Conflict resolution support for a project (0) objection (0)Reply Reference#3楼 [Landlord] 2014-09-20 18:40 Life One@ Beef Brisket
Excuse me, every time I modify. gitignore ignore the file, do I need to re-commit this file? Support (0) objection (0)Reply Reference#4楼2014-09-20 20:02 Brisket@ Life One #
A commit is required, or the. gitignore file downloaded when someone downloads it is still in GBK format, so the Chinese folder cannot be ignored. Support (0) objection (0)Reply Reference#5楼 [Landlord] 2014-09-21 20:45 Life One@ Beef Brisket
Hello, I am in the development of Android, obviously already put the bin folder inside to ignore the file, and will also ignore the file commit commit, why in the git status command, still appear in the Bin folder modification information? Support (0) objection (0)Reply Reference#6楼2014-09-26 12:00 Brisket@ Life One #
In the. gitignore file, the notation is bin/.
I'm guessing you're wrong about it. As soon as I wrote it, it worked. Support (0) objection (0)Reply Reference#7楼 [Landlord] 2014-09-26 13:16 Life One@ Beef Brisket
That's what I wrote. Could you send me my e-mail for the. gitignore file of your Android project? I compare. e-mail: [email protected], thank you. Support (0) objection (0) http://www.cnblogs.com/smyhvae/p/3981720.html

Git version control (i)

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.