GithubHelp home page GithubHelp logo

zhouweiwei18 / learngit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from onerme/learngit

0.0 0.0 0.0 30 KB

Git学习笔记---廖雪峰Git教程

Home Page: https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

learngit's Introduction

git常用命令速查表

查看

git status查看工作区

git diff <file>查看差异

git branch查看本地分支

git reflog历史命令记录

git log查看历史提交记录

git remote查看远程库的信息

git remote -v显示更详细的远程库信息

git log --pretty=oneline --abbrev-commit查看历史提交记录简略列表

git log --graph查看分支合并图

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"git lg简写由来

创建版本库

git init初始化本地版本库

$ git config --global color.ui trueGit会适当地显示不同的颜色

git config --global user.name "Your Name"设置Git全局用户名

git config --global user.email "[email protected]"设置Git全局邮箱

git add <filename>提交到暂存区

git add -f <filename>强制添加到Git暂存区

git check-ignore -v <filename>提交不成功,查看是为否排除文件

git config --global alias.st status命令简写

git commit -m "wrote a readme file"一次性把暂存区的所有修改提交到分支

git status查看仓库状态

git diff <file>查看差异

git log查看历史提交记录

git log --pretty=oneline --abbrev-commit查看历史提交记录简略列表

修改

git reset --hard HEAD^回退到上一个版本

git reset --hard commit_id回退到某个版本

git checkout -- file丢弃工作区的修改

git reset HEAD file撤销掉暂存区的修改

git rm删除版本库中文件,删除之后还需提交

git checkout -- filename用版本库里的版本替换工作区的版本

远程仓库

git push origin branch-name把该分支上的所有本地提交推送到远程库

ssh-keygen -t rsa -C "[email protected]"创建SSH Key

git remote add origin [email protected]:onerme/learngit.git本地仓库关联GitHub仓库

git push -u origin master把当前分支master推送到远程仓库,只有第一次加-u

SSH连接在第一次验证GitHub服务器的Key时,需要你确认GitHub的Key的指纹信息是否真的来自GitHub的服务器,输入yes回车即可。

git clone克隆远程版本库

git remote rm <remotename>删除已有的GitHub远程库

git checkout -b branch-name origin/branch-name在本地创建和远程分支对应的分支

分支管理

git branch <name>创建分支

git checkout <name>切换分支

git checkout -b <name>创建+切换分支

git merge <name>合并某分支到当前分支

git branch -d <name>删除分支

git branch -D <name>强行删除分支

git push origin :br删除远程分支(origin 后面有空格)

git merge --no-ff -m "merge with no-ff" dev表示禁用Fast forward

git pull获取最新提交

git branch --set-upstream branch-name origin/branch-name指定本地分支和远程分支的链接关系(如果git pull提示“no tracking information”)

工作区

git stash隐藏工作区

git stash list查看隐藏工作区

git stash apply恢复隐藏工作区,但stash内容并不删除

git stash drop删除stash内容

git stash pop恢复隐藏工作区,删除stash内容

标签管理

git tag <name>添加新标签

git tag查看所有标签

git show <tagname>查看标签信息

git tag -a v0.1 -m "version 0.1 released" 3628164创建带有说明的标签,用-a指定标签名,-m指定说明文字

git push origin <tagname>推送一个本地标签

git push origin --tags推送全部未推送过的本地标签

git tag -d <tagname>删除一个本地标签

git push origin :refs/tags/<tagname>删除一个远程标签

learngit's People

Contributors

onerme avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.