felix-cao / Blog

A little progress a day makes you a big success!
31 stars 4 forks source link

Git commands #8

Open felix-cao opened 6 years ago

felix-cao commented 6 years ago

Here is a list of some basic Git commands to get you going with Git.

For more detail, check out the Atlassian Git Tutorials for a visual introduction to Git commands and workflows, including examples.

git 官方给的教程

一、Git 常用命令速查列表

Summary Commands Tips
全局配置 $ git config --global user.name "Your Name"
$ git config --global user.email "name@eb.com"
《Git 配置文件》 #9
查看配置 $ git config --list
$ git config --list --global
创建仓库 $ git init
把目录变成 git 可以管理的仓库
掌握仓库状态 $ git status
查看修改 $ git diff readme.txt
$ git diff HEAD readme.txt
Git diff 场景解读
提交修改/新文件 $ git add readme.txt
提交 $ git commit -m "add distributed" 提交到版库
查看提交日志 $ git log
$ git log --pretty=oneline
$ git log --oneline --graph
More
命令日志 $ git reflog
$ git reflog --relative-date
$ git reflog --date=iso
版本回退 $ git reset --hard commit_id
$ git reset –hard HEAD^
撤销修改 $ git checkout — filename
$ git reset head file
删除 $ rm file
$ git rm file
$ git commit
删除也是一个修改操作
远程库添加 $ git remote add <主机名> <网址>
远程库删除 $ git remote rm <主机名>
$ git remote remove <主机名>
远程库重命名 $ git remote rename <原主机名> <新主机名>
远程库查看 $ git remote
$ git remote -v
More
远程库详细信息 $ git remote show < hostname >
推送到远程库 $ git push -u origin master
克隆 $ git clone <远程库网址> More
创建分支 $ git branch branchName
$ git checkout -b <分支名>
More
分支重命名 $ git branch –m oldName newName
切换分支 $ git checkout branchName
查看分支 $ git branch
$ git branch -r
$ git branch -a 查看本地所有分支
当前分支前会标一个*号
合并分支 $ git merge branchName
$ git cherry-pick 合并某个commit ID 到当前分支
合并指定分支到当前分支
删除分支 $ git branch -d <分支名> 删除时提示分支没有合并
$ git branch -D <分支名>
分支重命名 $ git branch -m oldname newname
删除远程分支 $ git push origin :bug 删除远程 origin 主机的 bug 分支
推送到远程 $ git push <远程分支> <本地分支>
取回更新 $ git fetch <远程主机名>
$ git fetch <远程主机名> <分支名>
More
取回并合并 $ git pull <远程主机名> <远程分支名>:<本地分支名> More
推送 $ git push <远程主机名> <本地分支名>:<远程分支名> More
追踪关系 tracking More
储藏 git stash
储藏列表 git stash list
应用储藏储藏 git stash pop More

二、部分命令说明

2.1、git log

2.2、远程库查看

2.3、git clone

2.6、git pull

2.7、git push

2.8、tracking追踪关系

felix-cao commented 5 years ago

git reflog --date=iso

git 基础--打标签