Git Cheat Sheet Chinese

----------------戴维营教育整理--------------------

索引


创建

复制一个已创建的仓库:

$ git clone ssh://[email protected]/repo.git

创建一个新的本地仓库:

$ git init

本地修改

显示工作路径下已修改的文件:

$ git status

显示与上次提交版本文件的不同:

$ git diff

把当前所有修改添加到下次提交中:

$ git add .

把对某个文件的修改添加到下次提交中:

$ git add -p <file>

提交本地的所有修改:

$ git commit -a

提交之前已标记的变化:

$ git commit

附加消息提交:

$ git commit -m ‘message here‘

Commit to some previous date:

git commit --date="`date --date=‘n day ago‘`" -am "Commit Message"

修改上次提交
Don‘t amend published commits!

$ git commit --amend

把当前分支中未提交的修改移动到其他分支

git stash
git checkout branch2
git stash pop

搜索

从当前目录的所有文件中查找文本内容:

$ git grep "Hello"

在某一版本中搜索文本:

$ git grep "Hello" v2.5

提交历史

从最新提交开始,显示所有的提交记录(显示hash, 作者信息,提交的标题和时间):

$ git log

显示所有提交(仅显示提交的hash和message):

$ git log --oneline

显示某个用户的所有提交:

$ git log --author="username"

显示某个文件的所有修改:

$ git log -p <file>

谁,在什么时间,修改了文件的什么内容:

$ git blame <file>

分支与标签

列出所有的分支:

$ git branch

切换分支:

$ git checkout <branch>

基于当前分支创建新分支:

$ git branch <new-branch>

基于远程分支创建新的可追溯的分支:

$ git branch --track <new-branch> <remote-branch>

删除本地分支:

$ git branch -d <branch>

给当前版本打标签:

$ git tag <tag-name>

更新与发布

列出对当前远程端的操作:

$ git remote -v

显示远程端的信息:

$ git remote show <remote>

添加新的远程端:

$ git remote add <remote> <url>

下载远程端版本,但不合并到HEAD中:

$ git fetch <remote>

下载远程端版本,并自动与HEAD版本合并:

$ git remote pull <remote> <url>

将远程端版本合并到本地版本中:

$ git pull origin master

将本地版本发布到远程端:

$ git push remote <remote> <branch>

删除远程端分支:

$ git push <remote> :<branch> (since Git v1.5.0)
or
git push <remote> --delete <branch> (since Git v1.7.0)

发布标签:

$ git push --tags

合并与重置

将分支合并到当前HEAD中:

$ git merge <branch>

将当前HEAD版本重置到分支中:
Don‘t rebase published commit!

$ git rebase <branch>

退出重置:

$ git rebase --abort

解决冲突后继续重置:

$ git rebase --continue

使用配置好的merge tool 解决冲突:

$ git mergetool

在编辑器中手动解决冲突后,标记文件为已解决冲突

$ git add <resolved-file>
$ git rm <resolved-file>

撤销

放弃工作目录下的所有修改:

$ git reset --hard HEAD

移除缓存区的所有文件(i.e. 撤销上次git add):

$ git reset HEAD

放弃某个文件的所有本地修改:

$ git checkout HEAD <file>

重置一个提交(通过创建一个截然不同的新提交)

$ git revert <commit>

将HEAD重置到上一次提交的版本,并放弃之后的所有修改:

$ git reset --hard <commit>

将HEAD重置到上一次提交的版本,并将之后的修改标记为未添加到缓存区的修改:

$ git reset <commit>

将HEAD重置到上一次提交的版本,并保留未提交的本地修改:

$ git reset --keep <commit>

 

时间: 2024-07-29 17:10:38

Git Cheat Sheet Chinese的相关文章

git cheat sheet,git四张手册图

139.00.007 Git学习-Cheat Sheet

@(139 - Environment Settings | 环境配置) Git虽然极其强大,命令繁多,但常用的就那么十来个,掌握好这十几个常用命令,你已经可以得心应手地使用Git了. 友情附赠国外网友制作的Git Cheat Sheet,建议打印出来备用: Git Cheat Sheet 现在告诉你Git的官方网站:http://git-scm.com, 英文自我感觉不错的童鞋,可以经常去官网看看.什么,打不开网站?相信我,我给出的绝对是官网地址,而且,Git官网决没有那么容易宕机,可能是你的

MySQL SQL Injection Cheat Sheet

MySQL SQL Injection Cheat Sheet Some useful syntax reminders for SQL Injection into MySQL databases- This post is part of a series of SQL Injection Cheat Sheets.  In this series, I've endevoured to tabulate the data to make it easier to read and to u

XSS (Cross Site Scripting) Prevention Cheat Sheet(XSS防护检查单)

本文是 XSS防御检查单的翻译版本 https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet 介绍 本文描述了一种恰当地使用输出转码或者转义(encoding or escaping)防御XSS攻击的简单积极模式. 尽管存在巨量XSS攻击方式,遵守一些简单的规则能够彻底防住这类严重的攻击. 本文不探讨XSS攻击的商业和技术影响. reflected and stored XSS 可以

转:PostgreSQL Cheat Sheet

PostgreSQL Cheat Sheet CREATE DATABASE CREATE DATABASE dbName; CREATE TABLE (with auto numbering integer id) CREATE TABLE tableName ( id serial PRIMARY KEY, name varchar(50) UNIQUE NOT NULL, dateCreated timestamp DEFAULT current_timestamp ); Add a pr

A printf format reference page (cheat sheet)

Summary: This page is a printf formatting cheat sheet. I originally created this cheat sheet for my own purposes, and then thought I would share it here. A cool thing about the printf formatting syntax is that the specifiers you can use are very simi

The iOS Design Cheat Sheet 界面设计速参

http://ivomynttinen.com/blog/the-ios-7-design-cheat-sheet/ With the release of iOS 7, app designers and developers will need to adjust their visual language to match the new "flat" design of iOS. In addition to the grid system, the dimensions of

Windows平台Atom编辑器的常用快捷键小抄Cheat Sheet

博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:Windows平台Atom编辑器的常用快捷键小抄Cheat Sheet. Windows平台Atom编辑器的常用快捷键小抄Cheat Sheet

A Cheat Sheet for HTTP Libraries in C++

Unfortunately, standard C++ library provides no tools for working with HTTP protocol. Therefore, when we want to run some REST service, parse a webpage or write a simple bot or web crawler, we always wonder which library is better and faster in use.