Git tutorial (ii) The first knowledge of git

Source: Internet
Author: User
Tags commit

After installing Git is not eager to practice practiced hand, then we start now.

test Environment: Operating system--windows XP, software--git for Windows, operating terminal--git Bash

The first thing to do is to prepare, find a suitable location to create an empty directory, and then choose to create an empty directory named Git under the E-drive. Once we're done, we can get access to git init, the first command to use Git.

command: Git init

With this command, we can instantly change a directory into a repository (also known as a repository) that git can manage, and you'll be prompted to use it as an empty repository, because we haven't put anything in it yet. We'll come back to the new Git directory and we'll find that there's one more. Git directory (the directory that starts with the. Ls-a in Linux is not displayed by default and can be used to show all files), which is what git uses to manage the repository, not to manually modify the files inside, which destroys the repository. Do not delete it, delete it, the directory is a normal directory.


command: git add <file>

"Git init" when the system has already prompted us this is an empty warehouse, then how to put things in this empty warehouse, this time need to use the git add command. Prior to this, Let's start with a new file that needs to be added readem.md, if you have used github.com or git.oschina.net friends believe that this file is not unfamiliar, we create a new warehouse will be prompted whether to create a new document such as this, we also do as the Romans do, create a new description document.

git add readme.md
We found that the addition was done without any hint, which is right, because Unix has always been adhering to the "no news is the best news", I believe that the use of Linux friends should be accustomed to this situation. Of course, if the file you added to the repository does not exist, Git will still give you a hint, as shown in the following figure.


Expand your knowledge

There are too many files that have not been added. Add a lot of trouble. Okay, we just need to improve the git add command.

git add-a

This allows you to add all files that have not been added to the library at once.

tips: Git add can be added to the file only within the warehouse, the outside of the warehouse files cannot be added.


command: Git commit-m "remark"

Add is added, commit is commit, this time a lot of friends may be confused, since the previous use "git add" added to the warehouse, this will be superfluous again to submit again. Let's make an analogy (perhaps not very image), we likened the "git add" operation to the buyer, his task is to transport the goods to the warehouse, and "Git commit", is the warehouse manager, he is responsible for the registration of goods in the book. Imagine that if there is no warehouse manager on these goods statistics, warehouse cargo information may be a mess, the warehouse in what we do not know, and even when the warehouse lost what goods are not known, it is obvious how important the warehouse manager. So what's the back-M? We have to submit what things always have an introduction to it is not, just like we put the goods into storage, always explain what the goods in storage, what time storage, the number is how much and so on. -M has played such a role, we did commit, there must be a reason, we need to write the reason, so that it is convenient for us to see why we have to do such a commit (if not to explain, maybe later we do not know why to do this commit operation), It is also possible to make it clear to others that you have done this submission for any purpose in a multi-person collaboration.


Summary

1. Initialize git repository git init

2. Add files to git repository git add

3. Commit files to git repository git commit

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.