Git use notes on the client

Source: Internet
Author: User
Tags git client

The new project uses Gitlab as the version management tool, installs the GIT client on the new server, now uses some of its own commands to write down, adds the memory, also facilitates oneself later to examine.

First, clone the code from the remote version server to the local test server:

1, git clone-b <branch> <remote_repo> for example: git clone-b specified branch name clone specified branch

[[Email protected] ~] $git clone-b preview Http://username:[email protected]/project/project. Git

2. If you are cloning the default branch code, use the following command directly:

[[Email protected] ~] $git clone http://username:[email protected]/project/project. Git

3. If the local server already has a corresponding branch, update it with the following command:

[[Email protected] ~] $git Fetch origin master[[email protected] ~] $git Checkout

4. If the code is inconsistent, use the following command to merge the code to keep it consistent with the version server

[[Email protected] ~] $git Merge origin/master final merge [[email protected] ~] $git Pull update and merge branch code

Second, submit code from the local test server to the version server

1. Git add--add local file

[[Email protected] ~] $git add A.py[[email protected] ~] $git Add b.py

[[Email protected] ~] $git Add c.py
2. Git commit--Commit changes

[[Email protected] ~] $git commit-m "Instructions for this submission"

3. Git push-pushes changes to the server

[[Email protected] ~] $git push

Third, version fallback problem

Remote code Library Fallback, it is necessary to first after the local fallback, and then push the project to the version server above, our main version is private, not directly fallback, we have to fallback the preview version to achieve fallback.

1. Check if the local branch is consistent with the version server

[[Email protected] ~] $git Checkout Preview

2, if not consistent, update the local branch

[[Email protected] ~] $git Pull

3, back up the current situation of this branch

[[Email protected] ~] $git Branch Preview_backup

4. View current Version information

[[Email protected] ~] $git Log

Commit A54342b1c493d30d2da7608e3c2140def8e03668author:luzhenshen <[email protected]>date:tue 10 15:58:30 +0800b.pycommit F674a93321490809b160c800cbef8946c45e7dfdauthor:luzhenshen <[email Protected]>date:tue 15:58:03 +0800a.pycommit 2f165dd17194b6134ac7a6098e1dc8eb4860dc27author: <E5><8C><97> <E4><BA><AC><E6><98><93><E8><81><94><E8><BE> <BE><E5><95><86><E5><8A><A1><E6><9C><8D><E5> <8A><A1><E6><9C><89><E9><99><90><E5><85><AC> <E5><8F><B8> <[email Protected]>date:mon 9 14:58:37 +080033commit 11cb2119cf651865a1aed7b863e607eb52e3050aauthor:huangzhijie <[email Protected]>date:mon May 9 15:54:07 2016 + 0800add Open Source Flask


Get the Commit ID:

2f165dd17194b6134ac7a6098e1dc8eb4860dc27
5. Roll back local to the_commit_id
[[Email protected] ~] $git Reset--hard 2f165dd17194b6134ac7a6098e1dc8eb4860dc27
6. Delete Remote Branch

[[Email protected] ~] $git push Origin:p review

7. Re-establish the remote branch with the local branch after rollback

[[Email protected] ~] $git Push Origin preview

8. Delete the backup branch

[[Email protected] ~] $git push Origin:p review_backup    Delete remote branch [[email protected] ~] $git branch-d preview_backup       Delete local Branch

Git use notes on the client

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.