Git 常用命令
来源:互联网 发布:软件编程培训机构地址 编辑:程序博客网 时间:2024/05/22 15:46
1.配置用户名和邮箱
git config --global user.name "Kirk"git config --global user.email "9123@qq.com"
2.创建文件夹
mkdir test
3.显示当前目录
pwd
4.把目录变成git可以管理的仓库
git init
5.添加文件到暂存区
git add 文件名
6.把文件提交到仓库
git commit -m "注释"
7.查看文件状态
git status
8.比较文件变化
git diff 文件名
9.查看历史记录
git log
10.简化查看历史记录
git log pretty=oneline
11.回退版本
git rest --hard HEAD^多个版本可以跟多个^^^也可git reset --hard HEAD~100还可回退指定版本号 git reset --hard 版本号
12.获取版本号
git reflog
13.撤销命令
git checkout --文件名
注意:命令git checkout — readme.txt 中的 — 很重要,如果没有 — 的话,那么命令变成创建分支了
14.删除文件
rm 文件名彻底删除文件需要加git commit命令
15.创建SSH Key
ssh-keygen -t rsa –C "youremail@example.com"
16.提交远程仓库
(1)git remote add origin https://github.com/tugenhua0707/testgit.git(2)git push -u origin master(3)输入github用户名和密码
17.克隆远程项目
git clone github地址
18.创建和合并分支
查看分支:git branch 查看分支,会列出所有的分支,当前分支前面会添加一个星号;创建分支:git branch name;切换分支:git checkout name;创建+切换分支:git checkout –b name;合并某分支到当前分支:git merge name;删除分支:git branch –d name;
19.工作现场
(1)隐藏当前工作现场:git stash;(2)查看当前工作现场:git stash list;(3)恢复工作现场:git stash apply恢复,恢复后,stash内容并不删除,你需要使用命令git stash drop来删除、另一种方式是使用git stash pop,恢复的同时把stash内容也删除了;
20.查看远程库信息
1.要查看远程库的信息 使用 git remote;2.要查看远程库的详细信息 使用 git remote –v
阅读全文
0 0
- git 常用命令
- Git常用命令
- git 常用命令
- git 常用命令
- git 常用命令
- git 常用命令
- GIT常用命令
- git 常用命令
- git 常用命令
- Git 常用命令
- git 常用命令
- Git常用命令
- Git常用命令
- git 常用命令
- Git 常用命令
- git常用命令
- git 常用命令
- Git 常用命令
- 日常刷题之金钩钓鱼(拉马车)的扑克牌游戏
- vue组件的初步理解
- 268. Missing Number
- Git 初始设置
- wordpress迁移站点
- Git 常用命令
- (四)流程控制
- C语言求1/n的和,
- 【python + PIL】图像相似度检测
- 我也开始记录我学编程的点点滴滴!
- 安卓x86虚拟机配置
- Mac sublime 编辑 html 快捷键没用的解决方法
- 考题篇(5.4) NSE4 16. 高级IPsec VPN ❀ 飞塔 (Fortinet) 网络安全专家
- ZOJ3209 Treasure Map(DLX精确覆盖)