Git: basic operations of Common commands and git operations

Source: Internet
Author: User
Tags how to use git

Git: basic operations of Common commands and git operations

I have been using cvs, svn, or the little turtle client for development. I have never heard that Git is powerful and useless, git is also used by the company. At this time, I need to know exactly how to use Git. Next, Git learns some records.

Step 1: select a version for your system. Default installation path.

Step 2: Simulate the use of the Git management tool locally. First, create a repository in the local directory (eg: D:/reps/) (corresponding to the remote repository in actual development, that is, the private server in the company intranet) click git-bash.exe and find the Created directory. Use cd/D/reps/And then git init -- bare library name (use the English name whenever possible). eg: git init -- bare MyFirstGitReps

Step 3: create a user in your directory (eg: D/user/user01) and clone the company project from the company's private server like a company development colleague. Here we create a warehouse (D:/reps/) clone from step 2.

Eg: git clone/D/reps/MyFirstGitReps. here is a point that represents the current directory. At this time, you will find a folder git (if not, it may be that the hidden file needs to be set to display) create two users. Similarly, create a second user in user/user02, which is similar to two colleagues. Develop a project together.

Step 4: At this time, our warehouse is empty and we need to upload something. Create a file named hello.txt in the user01 or user02 directory and write a little data (in English as much as possible) to save it. On the git command interface, enter cd to the directory hello.txt we just created. Check the git status and check the file status. It is not managed with git, execute git add Hello.txt in git status to find that we need to submit and then git commit-m "First Step commit"-m means a commit description. Enter instructions later. At this time, we have not submitted hello.txt to the remote warehouse, that is, our local warehouse. At this time, we need to execute git push origin master to submit it to the local warehouse. The first operation will remind you who you need to execute: git config user. name = "Drj" git config user. email = "123456789@qq.com.

Step 5: Switch another cd user. At this time, we need to pull the local repository, that is, the private server of the company, to your local server. Execute git pull and you will find the Hello.txt just submitted by this user. You can also modify it. After saving it, add Hello.txt git commit-m "user02 update" git push origin master to complete code submission.

The above five steps are basic operations, but there will usually be version conflicts. You have modified hello.txt and submitted it. Others have also modified the file. After that, you cannot submit it. In this case, the conflict must be resolved.

Git pull is automatically merged for you. Appears

HEAD to ======== your own ====== to "is the server, you need to determine which ones are not needed and then you can also delete tags when you do not need to delete them. Then add commit push

OK conflict resolution.

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.