Git and repo usage experience

Source: Internet
Author: User
Tags git commands
Git repo usage experience

Git is a version control tool similar to SVN and CVS. Repo encapsulates git operations to simplify git commands,

The GIT learning website was previously viewed by myself, but it encountered many difficulties in actual work operations, conflicts, and failure to submit. Currently, it is still not very familiar with GIT usage, but now I have a basic understanding of how to use it.

When git is used, repo is used and developed in windows. cygwin is used, which is better than bash in git. You must understand that the ADD and commit operations do not remotely operate images.CodeRepository. Code is pushed to a remote repository only after pushing is performed, which is one step more than SVN. The following uses my operations as an example:

1. mkdir gitlearn

2. CD gitlearn

3. Repo init-u SSH: // XXX-m xxx. xml pull remote code

This is actually equivalent to the two operations of git:

Git init

Git clone git@github.com: wufengxyz/hellogit. Git this is a repository on my GitHub and this website also provides a guide to learn about git

4. repo start XXX <project...> create a branch. You can create multiple projects on the project. These projects are to be modified by yourself. You must open the branch when using git. Otherwise, the conflict cannot be solved,

This is equivalent to git branch XXX (branch name) git checkout XXX. Create a branch and switch to this branch (repo can operate on multiple projects and modules, while git is a single project)

5. Go to a branch project, git branch-A, and check whether it is on the branch.

6. Git status. You must use multiple commands to view the modification status.

7. start modifying and adding operations on the branch.

8. After modifying the code, use

Git add.

Git commit-M "bug fixes"

9. You can synchronize the remote code.

Repo sync XXX (project name)

10. Now the remote code has been down. I believe that there may be any conflict.

If there are conflicting modifications, use git rebase -- continue after the modifications, which is equivalent to merging these modifications into the submission of the last conflict.

11. The repo upload operation pushes the code to the remote code review repository. Our leader will review our code and complete the development task without modifying it.

12. If review fails, you need to perform the following operations. Note that our Code has been submitted to the remote repository, which is different from the GIT rebase operation.

After the code that fails to be modified is completed, git Add., git commit-M "XXX" has completed a commit, and then use

Git rebase-I head ~ 2

A page is displayed.

Pick 0b92779 test commit two Pick 9d80074 rebase Test Merge the pick twice and change the second pick to S, as shown below: Pick 0b92779 test commit two S 9d80074 rebase Test ESC: WQ save changes a pop-up interface that deletes the next one Change-ID (DD operation, delete the entire row) ESC: WQ: Save the change and then repo upload the modified Code to complete all the submission processes. After the change is complete, a repo sync will be conducted to synchronize the remote repository code, remember to use the GIT status or repo STATUS Command frequently. You must perform Step 1 before each modification. Next we will introduce the solution if git cannot submit and use it at all, often because it does not open a branch. We will back up the modified code first, next, Repo sync synchronizes the latest code in the remote code library, and then overwrites the latest code with the backup code. After this operation, you will find that you have modified the code by using git status, then, in the IDE project, let's see what is different from the latest remote code. Add the code that is included in the remote code but not included in the current Code, and then proceed to the normal submission process, why do you think this is equivalent to making changes to the latest code. These are only the most basic operations in git and hope to help those who have just used 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.