Git 实用命令

http://iissnan.com/progit/  gitPro

Lrarn Git Branching

一.Git

 

  • Workspace:工作区
  • Index / Stage:暂存区
  • Repository:仓库区(或本地仓库)
  • Remote:远程仓库
  • 工作区:就是你在电脑里能看到的目录。
  • 暂存区:英文叫 stage 或 index。一般存放在 .git 目录下的 index 文件(.git/index)中,所以我们把暂存区有时也叫作索引(index)。
  • 版本库:工作区有一个隐藏目录 .git,这个不算工作区,而是 Git 的版本库。

二.同步、提交代码

同步

1
2
3
同步代码:
git fetch 
git pull origin  master 拉取指定分支代码合并到当前分支

 提交    

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
提交步骤:
git status   确认修改的文件内容;
 
git add --all   提交修改文件内容到暂存区;
 
git commit -am  " "   提交到本地;
 
例如: git commit -am '
 
ZK_RXXX_RK3288_ANDROID5.1
1.修改录音声音小;
2.修改uart0为uart1,uart1为uart4;
3.修复休眠唤醒,概率性无作用;
4.修改README.md
'
 
git push origin  master   提交到服务器;

  

三.回退已提交版本

1
2
3
4
5
6
7
git reset<版本号>   回退到指定版本。指定版本号可通过git log查看,注:不需要携带--hard,可使用--soft
git stash           暂存修改
git push  --force   强制push 到远程仓库吗,指定版本往后的commit均被删除
git stash pop       释放暂存的修改
git add.            暂存所有修改
git commit -m "message"   提交已暂存的文件
git push origin master    推送至远程仓库

 实例

 

 

四.查看某节点详细信息

1
2
git show <版本号> --stat
git show 2159d8788ec5959aabff21f32c3cb720570f445b --stat

 

五.节点与节点之间生成差异文件

  

1
git diff b029cfaa56384770da2fdf671af53f88f340effb 05d041e768965950c778bdbd453b5f498901ca17 --name-only | xargs zip update.zip

 

六.查看代码地址

1
git remote show origin

  

1
2
3
$ git remote -v
origin  https://github.com/schacon/ticgit (fetch)
origin  https://github.com/schacon/ticgit (push)

  

七.使用git config --global设置用户名和邮件

1
2
git config --global user.email "you@example.com"
git config --global user.name "Your Name"

 查看用户自定义配置

1
2
3
$ git config --global --list
user.name=Gatsby
user.email=2186651339@qq.com

 

八.gitignore 不起作用的解决办法

1
2
3
git rm -r --cached .
git add .
git commit -m 'update .gitignore'

 在.gitgnore 中忽略 frameworks/base/api/current.txt

1
git rm -r --cached  frameworks/base/api/current.txt

 

九.git log --pretty=oneline

 

十.git diff new old --name-only | xargs zip update.zip  两节点打出zip包

  

  

  

posted @   CrushGirl  阅读(331)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
点击右上角即可分享
微信分享提示