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 log
Version 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.txt
Discard 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 master
Push all the contents of the local library to the remote library
$ git clone [email protected]:michaelliao/gitskills.git
Cloning from a remote library to GitHub
$ git clone [email protected]:michaelliao/gitskills.git
Cloning 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