0


Gitbash常用指令总结

Part I git 开始的指令

在这里插入图片描述

1、git init:初始化一个Git仓库;
2、git clone:从远程仓库克隆代码到本地;
直接使用网址

git clone <url>

or
用a代替网址

git remote add a <url>git clone a

3、git add:添加文件到暂存区;
文件名

gitadd<filename>

or
添加所有文件

gitadd *

4、git commit:将暂存区的文件提交到本地仓库;

git commit -m 'comment'

or
自动调出默认编辑器

git commit 

or
不用add

git commit -a -m 'comment'

5、git push:将本地仓库的代码推送到远程仓库;

git push <remote><branch>

won’t record that the local branch ‘master’ needs to be pushed to upstream (origin) ‘master’ (upstream branch)
6、git pull:从远程仓库拉取最新代码;
7、git branch:列出所有本地分支;
8、git checkout:切换分支或恢复工作树文件;

git checkout <tag or branch or ca82a6d>

9、git merge:合并指定分支到当前分支;
10、git status:显示工作树的状态;
11、git log:显示提交日志;
–graph option to see what divergent histories look like.
–decorate option to easily visualize where our branch
pointers are located
–all option 显示所有commit

git log --oneline --decorate --graph --all

12、git diff:显示工作树与暂存区或本地仓库之间的差异;
特定commit,特定文件,使用difftool比较

$git difftool HEAD:src/main/java/com.xyz.test/MyApp.java HEAD^:src/main/java/com.xyz.test/MyApp.java

13、git stash:将当前工作区的变更储存到一个临时区域;
14、git tag:添加、列出或删除标签;
15、git remote:管理远程仓库;
16、git fetch:从远程仓库拉取最新代码,但不自动合并到本地仓库;

Part 2 其他指令

1.用默认的软件打开文件

start <filename>
explorer <filename>
标签: git

本文转载自: https://blog.csdn.net/qq_43607588/article/details/131522066
版权归原作者 kikaku 所有, 如有侵权,请联系我们删除。

“Gitbash常用指令总结”的评论:

还没有评论