美文网首页
Git命令总结

Git命令总结

作者: 内心强大的Jim | 来源:发表于2016-05-17 20:57 被阅读23次

参考:

1.http://www.jianshu.com/p/118ce8bc6eee

2.http://www.jianshu.com/p/97946d9df5bd

CREAT(创建)

//在当前目录下创建一个本地库(Create a new local repository)

git init

//在远程库克隆一个本地库(Clone an existing repository)

git clone ssh://user@domain.tld/repo.git


Configuration(配置)

//设置提交时附带的名字(Set the name attached to all your commits)

git config [--global]user.name

//设置提交时附带的email(Set the email attached to all your commits)

git config [--global]user.email

//设置命令行输出回执的颜色(Set colorzition of command line output for all repository)

git config --globalcolor.ui auto

//获取当前库设置的用户名(Print set name(in currentrepository or globally))

git config [--global]user.name

//获取当前库设置的email(Print set email(in current repositoryor  globally))

git config [--global]user.email


Local Changes(本地操作)

//查看工作区内的文件修改(List changed files in yourworking directory)

git status

//查看已追踪文件的修改(List changed to trackedfiles)

git diff

//添加此文件的所有修改在下次提交时(Add allcurrent changed in file to the next commit)

git add

//添加本地库中的所有修改在下次提交的时(Add allcurrent changed to the next commit)

git add .

//修改文件名并添加到下次提交当中(Rename file and add it tonext commit)

git mv

//删除此文件并将此处删除添加到下次提交当中(Delete fileand add its deletion to next commit)

git rm

//提交工作区所有文件(Commit all local changes in tracked files)

git commit -a


Commit History(提交历史)

//显示所有的提交日志(Show all commits)

git log

//这个文件的最后一次提交日志(Shwo changes over time fora specific file)

git log –p

//这个提交者最后一次的提交日志(Show changes over time fora specific committer)

git log--author=

//此文件被谁修改了(Who changed what and when in file)

git blame

//查看临时的文件变动(Store changes temporarily)

git stash

//删除上一次记录储蓄新的改动记录(Remove and apply changes)

git stash pop

//把此文件从过去的提交记录中删除但是保留当前本地的文件(Remvoe filefrom previous commits but keep it locally)

git rm --cached


Branches & Tags(分支和标签)

//本地所有的分支列表(List all existing branches)

git branch

//切换分支(Switch HEAD branch)

git checkout

//创建新分支(Creat a new branch based on your currentHEAD)

git branch

//创建一个新的分支基于一个远程的分支(Creat a new tracking branch based on a remote branch)

git branch --track

//删除一个本地分支(Delete a local branch)

git branch -d

//删除一个远程分支(Delete a remote branch)

git branch origin --delete

//重命名远程分支名(Rename a branch on remote)git push

git push :

//

git push

//给当前提交打一个tag,也可以查看当前标签(Tag the current commit)

git tag


Update & Publish(更新和提交)

//查看远程库的地址列表(List all currentlyconfigured remotes)

git remote -v

//查看这个远程库的信息(Show information about a remote)

git remote show

//添加新的远程库(Add new remote repository)

git remote add

//重命名远程库(Rename a remote)

git remote rename

//从远程库更新所有的信息到本地,但是不合并(Download allchanges from remote,but don't merge into HEAD)

git fetch

//从远程库更新所有的信息到本地,但是不合并并清理已删除的远程分支(Download all changes fromm remote,but don't merge inHEAD and clean up deleted branchs from origin)

git fetch -p

//从远程库更新数据并立即合并数据(Download changes and directly merge into HEAD)

git pull

//将本地数据同步到远程库中(Publish local changes on aremote)

git push

//追踪一个远程库(Track a remote repository)

git remote add --track

//同步标签到远程库(Publish your tags

git push --tags

//显示远程库信息(Show information about a submodule)

git remote show


Merge & Rebase(分支合并和重整数据)

//将其他分支和并到当前分支(Merge branch into yourcurrent HEAD)

git merge

//将亲她分支合并到当前分支并按照提交顺序排序(Rebase your current HEAD onto branch)

git rebase

//终止当前合并(Abort a rebase)

git rebase –abort

//解决冲突后继续当前合并和重整(Continue a rebase afterresolving confilcys)

git rebase –continue

//使用配置的合并工具解决冲突(Resolve conflicts using your configured merge tool)

git mergetool

//手动解决冲突使用编辑器并标记已解决的文件

git add

//

git rm

Undo(撤销)

//丢弃所有的本地修改(Discard all local changes in your workingdirectory)

git reset --hard HEAD

//丢弃此文件的本地修改(Discard local changes in aspecific file)

git checkout HEAD

//撤销某次的提交内容(Revert a commit by providing a new commit with contrary changes)

git revert 

//撤销某次提交的某个文件的内容(Revert a specific filefrom a previous commit)

git checkout


重置头指针到过去的某个提交上,版本回退(Reset your HEAD pointer to a previous commit)

//回退到某个版本(Discarding local changes)

git reset --hard 

//回退到某个版本并保存未追踪的改动

git reset

//回退到某个版本并保存未提交的改动

git reset --keep

相关文章

  • git入门

    这里对git init、git add、git commit命令进行一个总结。 $ git init 命令,该命令...

  • GIT 常用命令总结

    GIT 常用命令总结 GIT 初始化命令 命令描述git init初始化本地 git 仓库git config -...

  • git 命令汇总

    git 命令汇总 常用总结 1.$ git help 查看git所有命令的帮助 2.$ git config --...

  • git 命令

    Git常用命令总结Git常用命令总结 git init 在本地新建一个repo,进入一个项目目录,执行git ...

  • Git 常用指令

    Git常用命令总结 Git常用命令总结 git init 在本地新建一个repo,进入一个项目目录,执行git i...

  • Git 命令总结

    Git 命令总结 基本命令 远程仓库 分支管理 标签管理 自定义 Git 搭建 Git 服务器 安装 git:$ ...

  • Git与Github的使用总结 - day 03

    git常用命令总结 git配置(config): git仓库(repository): git分支(branch)...

  • git相关教程汇总

    1. git常用命令 git常用命令总结git常用命令讲解 2. git教程相关网站 廖雪峰的git教程猴子都能懂...

  • GitHub创建远程仓库及连接

    总结:使用的git命令 git init git remote add origin (远程仓库地址) git r...

  • Git命令整理

    由于Git命令较多,将常使用的Git命令做一下整理与总结。 Git初始化设置git config --global...

网友评论

      本文标题: Git命令总结

      本文链接:https://www.haomeiwen.com/subject/ecmkkttx.html