Linux Version Control-Git

Source: Internet
Author: User

I recently worked on the android IPTV project. In Linux, I am familiar with the version management tools on the platform. Note A LITTLE BIT:

1. Use sudo apt-Get install Git-core to install the GIT program.
2. Use git clone git: // git.kernel.org/pub/scm/git/git.git to update the version library.
3. Configure git
A. Use git config -- global user. Name "tiger" (enter the user name)
B. Git config-global user. Email xx@gmail.com (contact info)
4. Create a folder named Fawn.
Mkdir fawn
5. Enter fawn
CD fawn
6. Warehouse Initialization
Git init
7. Add the file hello. Java
Touch hello. Java
8. Add the file to the Management System (several statuses of the file under git management are changed, and files are saved for storage. 3. Files are submitted to the repository)

Git add hello. Java // Add a file to the temporary index and add it to the temporary storage before it can be submitted to the local repository.

(Add the new file hello. Java). The generated snapshots are stored in a temporary storage area. Git calls this area an index.

9. next, submit the file index to the repository and use the git-commit command to submit the index to the local git repository. This process is called commit. Each commit means that the version is updated.

A. Run git commit or git commit-m to submit your version information.

B. Submit git commit-M "version 1.0 hello. Java" in method 2"

Git commit-a-m 'submit information' // submit all the changed files that are added to the temporary index.

10. Git push remote repository name remote branch name r_branch // submit the local git repository to the remote git Repository

11. How do I get the latest code?

Method 1.git fetch remote r_branch git merge orgin_branch // first obtain the code from the remote server git repository and merge it to the local git

Repository, and then merge to the local working directory

Method 2: git checkout remote/r_branch // directly overwrite the remote branch to the local workspace, and the local git repository remains unchanged.

Method 3: git pull remote r_branch // run the remote branch pull to the local working directory, and the local git repository code remains unchanged.

Method 4: git pull // direct the remote branch to the local git repository and local working directory.

12. How do I cancel the operation?

Git reset -- hard head // undo it to the last submitted state, and the branch header Pointer Points to backward

Git reset -- hard o_branch @ {n} // n indicates the code for rolling back to the first commit.

13. Merge code

Git merge o_branch // run the code merge in the local git repository to the current working directory. The remote branches of merge are not supported. Fetch and pull can automatically merge.

14. Push code

Git push remote r_branch // submit the local branch o_branch to the remote repository r_branch branch to complete code Remote Server submission

15. Check the current branch and current code status, whether there are changes and

Git status (commonly used)

16. View local branches

Git Branch

17. view remote repository name view branch under remote Repository

Git remote git remote show remote_name

18. Create a branch

Git branch o_branch

Git checkout-B o_branch // create a local branch o_branch and capture this branch on the server

19. Switch to o_branch (A Branch)

Git checkout o_branch

20. delete a branch

Git branch-D o_branch

21. delete a file under the current Branch

Git RM **. XX (-F ignores whether changes are forcibly deleted)

Note: before switching the branch, make sure that all the modified files under the current branch are submitted to the temporary storage and all are commit. Otherwise, the switch will fail.

I just learned this recently. I hope to point out any improper expression. Stivenjin@gmail.com

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.