Git usage record

Source: Internet
Author: User

Git is a good version of the control tool, although the work is still using SVN, but the advantage of git is that it is not a centralized version control, on their own computer can also do their own version control, this is used in my usual writing some small program is still more useful, summarized under:

1. Command:

Initialize the GIT repository:

Git init

2. View Workspace Status:

git status

3. Add an image to the workspace to increase the deletion of the modified record:

Add * can be easily added all the changes, of course, you can also submit a file:

git add *

4. Submit the image to the version branch:

" msg "

(msg represents this submission, of course, can not write-M, the following vim will appear in the editing interface:)

This interface is Vim editor interface, the familiar person may be very convenient to edit the exit, here to the person who has not used vim, the simplest command, finished editing exit

1: Press "I" key to edit this document, and then press ":", the cursor focus on the first line, and then edit the submission instructions, after editing,

2: Press "ESC" key, the representative exits the edit mode, enters the command line mode, at this time, continues to press ":", the cursor focuses to the last line, enters "Wq", Can save exits (W, represents saves, Q, represents exits)

3: If you want to edit it again, press "ESC" to toggle between edit mode and command line mode.

5. Create a branch

Git branch Branchname

The representative created a branch with the name Branchname, and git created the master branch by default when initializing the space, generally in order to manage the local directory version, we would create a copy branch to save the content before the change.

6. Query Branch

Git branch

For example, there are two branches on behalf of the warehouse, with an * number indicating the current branch

7. Switch branches

git checkout New

The delegate switches to the branch named new.

8. Merging branches

git merge New

The branch that represents the name "new" is merged into the current branch, and the merge conflict has to be manually handled after the conflict is resubmitted,

If there is a conflict will merge failure, after the merge failed to check the file conflict place, manual processing, and then commit again.

To summarize, I'm doing my local version control steps:

Because the company can not use Git to link to GitHub and other code warehouses, so I can only do the local control after the file upload directly, this is my local do warehouse control one of the reasons, the general process is as follows:

Initialize git library--"Create new branch"--"write code in the newly branch-" write the merge code to the master branch-"Take the Master branch code to GitHub

After the next day, you can repeat the loop merge in the third step, write the code, merge, Submit ~ ~

Git usage record

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.