Summarize with GIT commands under Windows

Source: Internet
Author: User
Tags git commands

Here is a simple summary of the main commands git, easy to remember, the summary of the bad, please tolerate, thank you! Want to see detailed explanation, recommend Liao Xuefeng great God's tutorial, the address is as follows: Http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/

The following references to thereadme.txt均为提交的文件

1: Tell

$ git config --global user.name "Your Name"  --输入你的名字$ git config --global user.email "[email protected]"--输入你的邮箱

2: Create a repository

$ mkdir learngit  --创建一个子目录$ cd learngit  --切换到所要创建的子目录的上一层目录下$ pwd    --把这个目录变成Git可以管理的仓库

3: Add File to Repository

$ git add readme.txt   把readme.txt文件添加到暂存区
$ git commit -m "wrote a readme file"--Submit the file you just added to the GIT server file branch

4: Version Management

$ git status 查看文件状态
$ git diff readme.txt  查看各版本不同点
$ git logVersion Submission History
$ git reset --hard HEAD^Fallback to previous version
$ git reset --hard HEAD^^  Fallback to the previous version 
$ git log 中得到的版本号回退到对应的版本
git diff HEAD--readme.txt See the difference between the latest version in the workspace and the repository
$ git checkout -- readme.txtDiscard modifications to the workspace
$ rm readme.txt  删除文件

5: Remote repository associated with local repository

$ git remote add origin [email protected]:michaelliao/learngit.git  
$ git push -u origin masterPush all the contents of the local library to the remote library
$ git clone [email protected]:michaelliao/gitskills.gitCloning from a remote library to GitHub
$ git clone [email protected]:michaelliao/gitskills.gitCloning a local library
git merge  Commands are used to merge the specified branch to the current branch

6: Branch Management

Git Branch View branches:
git branch <name>  创建分支
git checkout <name> switch branches:
Git checkout-b <name> create + switch branches:
Git merge <name> Merge a branch to the current branch:
git branch-d <name> Delete branch:
git log --graph  You can see the branch merge diagram

7:bug Branch

$ git stash  当前工作现场“储藏”起来,等以后恢复现场后继续工作

$ git stash pop, back to the job site

8:Feature Branch

git branch -D <name>  丢弃一个没有被合并过的分支,Forcibly delete

9: Multi-person cooperation

$ git remote  查看远程库的信息

Summarize with GIT commands under Windows

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.