Git Study Notes (Continuous updates)

Source: Internet
Author: User
  1. Force Code Synchronization to remote code

    When the remote repository rolls back the Commit (2nd descriptions), the remote code is forcibly synchronized to the local

    # Update all the latest code remotely, but not merge or rebase
    git fetch --all
    # Directly reset the data to the master, and then update the fetch.
    git reset --hard origin/master
  2. Version rollback

    # Roll back the local version
    Git reset -- hard <commit_id>
    # Force submit to server

    Git push origin head -- force

  3. Create branch and remote Branch

    # Create a local branch

    Git checkout-B branch_name

    # Push to remote

    Git push origin branch_name

    # Set Tracing (default git pull and git push, otherwise git push origin branch_name is required for update)

    # If git push-u origin branch_name is used for the first push, skip this step.

    # Git push -- Set-upstream origin branch_name

    Git branch-u origin/branch_name

    # Used by collaborators

    # Update the remote branch list

    Git fetch Origin

    # Update a remote branch to the local machine and create a local branch

    Git checkout-B branch_name origin/branch_name

    # Delete a remote Branch (transferring a null pointer to the remote branch is equivalent to deleting it)

    Git push origin: branch_name

    # After the remote branch is deleted, other machines are synchronized.

    Git fetch-P

  4. Discard all modifications to the current Workspace

    Git checkout.

Git Study Notes (Continuous updates)

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.