1. 关于git bash常用指令 推荐博客:

史上最简单的 GitHub 教程 

猴子都能懂的GIT入门

Learn Version Control with Git for Free

Git Documentation 

Git Book

2. 常用指令:

git config --global user.name "名字"

git config --global user.email "邮箱"

git status 查看当前状态

git init 初始化本地仓库

git add “filename”

git commit –m “注释”

git log

git branch 查看分支

git branch a 创建分支a

git checkout a 切换到a分支

git merge a 将分支a合并到当前分支

git branch –d a 删除分支a

git branch –D a 强制删除分支a

git push origin master

git pull origin master  把远端origin的master分支的最新版本拉取到本地,自动merge

git fetch origin master  把远端origin的master分支的最新版本拉取到本地,不merge,较安全

git clone https://github.com/...  克隆远程仓库

git remote add origin https://github.com/...   关联远程仓库

git reset --hard 版本号       回滚到特定版本

git push -f origin master     将本地的当前版本强制提交到远程仓库中

注意:在我们向远程仓库提交代码的时候,一定要先进行pull操作,再进行push操作,防止本地仓库与远程仓库不同步导致冲突的问题。


These are common Git commands used in various situations:

start a working area (see also: git help tutorial)  

clone

Clone a repository into a new directory

init

Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)

add

Add file contents to the index

mv

Move or rename a file, a directory, or a symlink

reset

Reset current HEAD to the specified state

rm

Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)

bisect

Use binary search to find the commit that introduced a bug

grep

Print lines matching a pattern

log

Show commit logs

show

Show various types of objects

status

Show the working tree status

grow, mark and tweak your common history    

branch

List, create, or delete branches

checkout

Switch branches or restore working tree files

commit

Record changes to the repository

diff

Show changes between commits, commit and working tree, etc

merge

Join two or more development histories together

rebase

Reapply commits on top of another base tip

tag

Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)

fetch

Download objects and refs from another repository

pull

Fetch from and integrate with another repository or a local branch

push

Update remote refs along with associated objects

05-11 15:36