git 使用记录

git init   创建一个新的git repository

git clone    从远程

git status   git库现在文件变化情况,可以用git status -s 比较方便阅读。

git diff     去获取已经归纳进版本库的文件与内存中版本的变化,及没有git add 但是已经在库中的文件与内存中的版本变化

git diff --cached  去获取已经git add与内存中的版本变化

git diff HEAD  就是 git diff 加上 git diff --cached

git add    纳入到版本库中

git commit   -m 提交到本地版本库中

git  commit -a 自动将所有trace的都给提交

git reset HEAD  filename  将stage的文件退回到unstage的状态

git rm  将文件从stage状态彻底删除

git mv 将版本库文件改名

git branch 列出现在所有branch

git branch (branch name) 生成一个新的branch

git branch -d (branch name) 删除一个branch

git checkout (branch name)切换到一个branch中

git merge (branch name)将现在的branch与提供的branch合并

git log 显示日志

git log --oneline 一行显示一条日志

git remote 显示remote的repository名称

git remote -v 看到实际的repository地址

git remote add 添加新的repository地址

git remote rm 删除repository地址

git fetch 从远端的repository获得最新的代码,放到一个临时的branch中

git pull 从远端的repository获得最新的代码,并且merge

git push [alias] [branch] 将现在的代码push到远端alias指定的git库中的branch分支中


当然安装完成后,需要config相关配置

$ git config --global user.name "Firstname Lastname" Sets the name of the user for all git instances on the system
$ git config --global user.email "your_email@youremail.com"


原文地址:https://www.cnblogs.com/sidmeng/p/2377579.html