当前位置:网站首页>测试
测试
2022-06-23 17:32:00 【Jiaojiao】
git 常用命令
1. 配置提交者的账号和名称
git config --global user.email "github的邮箱"
eg:git config --global user.email "[email protected]"
git config --global user.name "github的用户名"
eg: git config --global user.name "hello"
2. 基本操作
git clone xxxxx #克隆项目,xxxx是项目地址,https格式的或者ssh格式的,均可
git status #查看文件的状态
git diff #查看对比文件修改前和修改后的变化
git add 文件名 #添加文件
git add 目录名/* #批量添加,目录可以使新建的
git rm 文件名 #删除文件
git rm -r 目录名/ #删除指定目录以及目录下的所有文件和子目录
git commit -m "提交注释" #提交
git push -u origin master #提交到远程,提示输入用户名和密码
3. 分支相关命令
1.查看分支
git branch #查看本地分支
git branch -r #查看远程分支
git branch -a #查看所有分支,包括本地和远程的分支
2.切换分支
git checkout dev #切换到dev分支上
3.创建分支
git checkout dev #在当前分支上创建dev分支
git checkout -b dev #在当前的分支上新创建的dev分支并切换到新的创建的dev分支上
git push origin dev #创建远程dev分支,本地dev分支必须存在
4.查看分支是从哪个分支上创建的
git reflog --date=local --all | grep dev #查看在dev分支上的操作
5.删除分支
git branch -d dev #删除本地dev分支
git push origin --delete dev #删除远程dev分支
6.分支的合并merge
git merge dev #将dev分支合并到当前分支(一般是master主分支)
git push #将当前分支代码push到远程分支上
7.查看commit记录
git log #打印所有的提交记录
git reflog show --date=iso <branch name> #查看分支的所有commit提交历史
git commit --amend #修改commit描述
git log <commit ID> # 打印从第一次提交到指定的提交的记录
8.还原提交记录
# 重置暂存区,但文件不受影响
# 相当于将用 "git add" 命令更新到暂存区的内容撤出暂存区,可以指定文件
# 没有指定 commit ID 则默认为当前 HEAD
$ git reset [<文件路径>]
$ git reset --mixed [<文件路径>]
# 将 HEAD 的指向改变,撤销到指定的提交记录,文件未修改
$ git reset <commit ID>
$ git reset --mixed <commit ID>
# 将 HEAD 的指向改变,撤销到指定的提交记录,文件未修改
# 相当于调用 "git reset --mixed" 命令后又做了一次 "git add"
$ git reset --soft <commit ID>
# 将 HEAD 的指向改变,撤销到指定的提交记录,文件也修改了
$ git reset --hard <commit ID>
9.查看当前分支创建的时间
git reflog show --date=iso <branchname>
10.撤销刚刚解决的未提交的冲突
git merge --abort #回归到解决冲突以前的状态
git merge --abort 相关解释: http://www.javashuo.com/article/p-rjprecmd-bx.html
11.撤销 add 的文件
git reset HEAD [file]
参考资料: https://blog.csdn.net/qq_29166327/article/details/123606604
边栏推荐
- leetcode刷题:哈希表04 (两数之和)
- Video anomaly detection data set (shanghaitech)
- MySQL -- classic interview questions
- New function! Qianfan magic pen apaas December capability monthly report
- Is it safe to open a stock account online in 2022?
- Redis 集群
- csdn涨薪秘籍之Jenkins集成allure测试报告全套教程
- 论文阅读 (57):2-hydr_Ensemble: Lysine 2-Hydroxyisobutyrylation Identification with Ensemble Method (任务)
- [sword finger offer] 45 Arrange the array into the smallest number
- Counter attack and defense (2): counter strategy against samples
猜你喜欢

CSDN salary increase secret script: Jenkins integrated allure test report complete tutorial

Deep understanding of padding

org. apache. ibatis. binding. BindingException: Invalid bound statement (not found):...

Paper reading (48):a Library of optimization algorithms for organizational design

README

"Tribute to a century old master, collect pocket book tickets"

Paper reading (47):dtfd-mil: double tier feature interpretation multiple instance learning for histopathology

【C工具】------点阵模拟测试2

Simpledateformat has thread safety problems in multi-threaded environments.

微信小程序startLocationUpdateBackground()简单实现骑手配送位置
随机推荐
[Wwise] there is no sound problem after Wwise is embedded in unity and packaged
[esp8266 - 01s] obtenir la météo, Ville, heure de Beijing
实现领域驱动设计 - 使用ABP框架 - 通用准则
Thesis reading (57):2-hydr_ Ensemble: lysine 2-hydroxyisobutyrylation identification with ensemble method (task)
科技互动沙盘是凭借什么收获人气的
芯片原厂必学技术之理论篇(4-1)时钟技术、复位技术
README
Self taught programming introduction, what language to learn first?
[sword finger offer] 46 Translate numbers into strings
Implementing Domain Driven Design - using ABP framework - repository
Kerberoasting without SPN
论文阅读 (47):DTFD-MIL: Double-Tier Feature Distillation Multiple Instance Learning for Histopathology..
Torch learning (I): environment configuration
基于FPGA的电磁超声脉冲压缩检测系统 论文+源文件
对抗攻击与防御 (1):图像领域的对抗样本生成
【故障公告】取代 memcached 的 redis 出现问题造成网站故障
Vulnerability in McAfee epolicy orchestrator
Leetcode 1218. 最长定差子序列(提供一种思路)
论文阅读 (58):Research and Implementation of Global Path Planning for Unmanned Surface Vehicle Based...
CSDN salary increase secret script: Jenkins integrated allure test report complete tutorial