Install git under Windows and create a repository, git common commands

Source: Internet
Author: User
Tags diff tag name using git

Reproduced in: http://www.cnblogs.com/nemotan/p/4655498.html

One, Windows install git

1. Download: http://msysgit.github.io/, install directly after download, open Gitbash

2. Configure user name and mailbox:

$ git config--global user.name "Your name"

$ git config--global user.email "[email protected]"

3. Create a new folder and execute Git init to make a fresh git library, and use ls-a to see the hidden. Git folder

4. Create a new file 1.txt and execute the command

5. Connect to remote Git

-Generate Ssh:ssh-keygen-t rsa-c "[email protected]", press the ENTER key during installation

-The user's home directory finds the. SSH directory and copies the contents of the Id_rsa.pub file and pastes it into the seeting-->ssh keys-->add ssh keys on the GIT website

-Put a warehouse on a git website named Test1, when the warehouse is empty and the local warehouse and remote repository are associated

Git remote add Origin https://github.com/nemotan/test1.git

Git push-u Origin Master

* * If you do not create a warehouse locally, you can clone to a local using git clone https://github.com/nemotan/learngit.git

Second, git common commands

"Basic Command"

  • mkdir creating a File cd file entry
  • Git init turns this directory into a repository that git can manage, generating. git files
  • git add readme.txt Adding files to the repository
  • Git commit-m "whrote a Readme file" submitted to the warehouse
  • Git status check the current state of the repository, tell Readme.txt to modify it, but not ready to commit
  • Git diff readme.txt display changes similar to Linux diff command
  • Git log shows the submitted log
  • git log--pretty=oneline show submit log Lite
  • git reset--hard commit_id fallback to the submitted version
  • git reflog view commit_id for fallback
  • git reset--hard head^ fallback to previous action ID
  • Git checkout--readme.txt undo changes must be added--
  • git reset HEAD file Undo Staging Area Modification
  • git rm test.txt deleting files from the repository
  • Git branch <name> creating a branch
  • git checkout <name> switch branches
  • Git checkout-b <name> create + Toggle Branch
  • Git Branch View branches
  • git merge dev merges Dev branch to current main branch
  • git branch-d <name> Delete branch
  • Git stash to store the current job site.
  • Git stash list view the stored work site
  • git stash apply/drop reply/delete
  • Git stash pop recovery and delete
  • Git Remote View information
  • git remote-v View Remote library details
  • Git push origin master pushes branches to remote libraries

"Multi-person writing mode"

    • Git push origin branch-name push its own changes
    • Git pull Merge
    • Git branch--set-upstream branch-name origin/branch-name establish local and remote branch connections

"Tag"

    • Git branch
    • git checkout Master
    • git tag v1.0 to tag the branch
    • git tag View all tags
    • git log--pretty=oneline--abbrev-commit view history Commit ID
    • git tag v0.9 6224937 to tag the ID
    • git tag View tags
    • Git show v0.9 View tags
    • git tag-a v0.1-m "version 0.1 relased" 3628164-a tag name-M description
    • git tag-s v0.1-m "version 0.1 relased" 3628164-s signed with private key-M description text
    • git tag-d v0.1 Delete tags
    • Git push Origin v1.0 pushes a tag to a remote
    • Git push origin--tags push all tags

Install git under Windows and create a repository, git common commands

Related Article

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.