Git-simple guide

Source: Internet
Author: User
Git-simple guide install gitwww.2cto. comJava code sudoapt-getinstallgit-core to create a new repository, create a new folder, open it, and then execute www.2cto. comJava code gitinit to create a new git repository. Check out the warehouse and execute the following command... git-simple guide install git www.2cto.com Java code sudo apt-get install git-core to create a new repository, create a new folder, open it, and then execute www.2cto.com Java code git init to create a new git repository. Check out the repository and execute the following command to create a clone version of a local repository: Java code git clone/path/to/repository if it is a repository on a remote server, your command will look like this: java code git clone username @ host:/path/to/repository workflow your local repository consists of three "trees" maintained by git. The first is your working directory, which holds the actual file; the second is the cache area (Index), which is like a cache area, saving your changes temporarily; the last is HEAD, the result of your last submission. You can add and submit changes to the cache by running the following command: Java code git add Git add. this is the first step in git's basic workflow. use the following command to actually submit changes: Java code git commit-m "code commit information" now, your changes have been submitted to the HEAD, but it hasn't arrived at your remote repository yet. Push changes your changes are now in the HEAD of the local repository. Run the following command to submit the changes to the remote repository: The Java code git push origin master can replace the master with any branch you want to push. If you have not cloned an existing repository and want to connect your repository to a remote server, you can run the following command to add: Java code git remote add origin In this way, you can push your changes to the added server. Branch branches are used to isolate feature development. When you create a repository, the master is "default ". Develop on other branches, and then merge them into the main branch. Create a branch named "feature_x" and switch it back to the main branch: Java code git checkout-B feature_x: Java code git checkout master and delete the new branch: java code git branch-d feature_x unless you push a branch to a remote repository, this branch is not what others see: Java code git push origin Update and merge: Update your local repository to the latest changes. execute: Java code git pull to get (fetch) and merge (merge) remote changes in your working directory. To merge other branches to your current branch (such as master), execute: Java code git merge In both cases, git tries to automatically merge the changes. Unfortunately, automatic merge does not succeed once and may lead to conflicts ). At this time, you need to modify these files to merge these conflicts (conflicts. After modification, you need to execute the following command to mark them as merged successfully: Java code git add Before merging the changes, you can also run the following command: Java code git diff Tags are recommended when they are created during software release. This is an old concept, and also exists in SVN. Run the following command to create a tag named 1.0.0: Java code git tag 1.0.0 1b2e1d63ff 1b2e1d63ff is the first 10 characters of the submission ID you want to mark. Use the following command to obtain the commit ID: Java code git log you can also use the few first digits of the commit ID, as long as it is unique. Replace local changes if you do something wrong (naturally, this is not possible), you can use the following command to replace local changes: Java code git checkout -- This command replaces the files in your working directory with the latest content in the HEAD. Changes that have been added to the cache and new files are not affected. If you want to discard all your local changes and commits, you can get the latest version on the server and direct your local branches to it: Java code git fetch origin git reset --hard origin/masterUseful tips built-in graphical git: Java code gitk color git output: Java code git config color. when the ui is true, only one line of comment is displayed. when the Java code shows a history record, only one line of comment is displayed: add files interactively to the cache zone: Java code git add-I
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.