当前位置: 首页 > news >正文

Linux git安装与部署

目录

git安装

1、下载与安装

2、配置git账号信息

创建本地仓库

1、创建本地代码库文件夹

2、创建项目代码本地仓库文件夹

3、进入到projCode目录下,创建git本地仓库

4、创建过滤文件.gitignore

5、添加.gitignore到git暂存区

6、提交.gitignore

7、将项目代码移动到projCode目录下

8、将项目代码添加git暂存区

9、提交项目代码到仓库中

git本地仓库操作常用命令

查看哪些文件做了修改(与版本做对比)

查看变更摘要

查看某文件变更内容

回退某文件的所有变更

将文件添加到git暂存区

文件添加到git暂存区后,想将其从暂存区中移出(撤销git add操作)

提交到版本库

取消某文件的版本追踪

 查看仓库的提交日志

 查看某项提交详情

 查看某文件的提交日志

Qt Creator中使用git

1、启用git插件

2、使用git插件操作本地仓库(支持git部分功能)


git安装

1、下载与安装
sudo apt install git
2、配置git账号信息
#设置邮箱
git config --global user.email "xxx@xxmail.com"
#设置用户名
git config --global user.name "yourName"

创建本地仓库

1、创建本地代码库文件夹
mkdir repos
2、创建项目代码本地仓库文件夹
mkdir projCode
3、进入到projCode目录下,创建git本地仓库
git init
4、创建过滤文件.gitignore

.gitignore内容可参考如下:

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.*.stackdump# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
#x64/
#x86/
build/
bld/
[Bb]in/
[Oo]bj/# Visual Studio 2015 cache/options directory
.vs/# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*# NUNIT
*.VisualState.xml
TestResult.xml# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c# DNX
project.lock.json
artifacts/*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc# Chutzpah Test files
_Chutzpah*# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile# Visual Studio profiler
*.psess
*.vsp
*.vspx# TFS 2012 Local Workspace
$tf/# Guidance Automation Toolkit
*.gpState# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user# JustCode is a .NET coding add-in
.JustCode# TeamCity is a build add-in
_TeamCity*# DotCover is a Code Coverage Tool
*.dotCover# NCrunch
_NCrunch_*
.*crunch*.local.xml# MightyMoose
*.mm.*
AutoTest.Net/# Web workbench (sass)
.sass-cache/# Installshield output folder
[Ee]xpress/# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html# Click-Once directory
publish/# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
## TODO: Comment the next line if you want to checkin your
## web deploy settings but do note that will include unencrypted
## passwords
#*.pubxml*.publishproj# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config# Windows Azure Build Output
csx/
*.build.csdef# Windows Store app package directory
AppPackages/# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs# RIA/Silverlight projects
Generated_Code/# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm# SQL Server files
*.mdf
*.ldf# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings# Microsoft Fakes
FakesAssemblies/# Node.js Tools for Visual Studio
.ntvs_analysis.dat# Visual Studio 6 build log
*.plg# Visual Studio 6 workspace options file
*.opt# LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xmldocs/
data/
src/Config.ini
#*.db
*.opendb
#*.ini
Makefile.Debug
Makefile.Release
Makefile
build_log.txt
5、添加.gitignore到git暂存区
git add .gitignore
6、提交.gitignore
git commit -m  "上传过滤文件.gitignore"
7、将项目代码移动到projCode目录下
命令:mv 原目录 新目录#文件结构如下:
$ tree ./repos -a  -L  2
./repos
└── projCode├── testProject├── .git└── .gitignore3 directories, 1 file
8、将项目代码添加git暂存区
git add .
9、提交项目代码到仓库中
git commit -m "提交项目代码"

git本地仓库操作常用命令

  • 查看哪些文件做了修改(与版本做对比)
git status
  • 查看变更摘要
#显示未添加到暂存区的变更摘要
git diff --stat
#显示已添加到暂存区的变更摘要
git diff --cached  --stat
  • 查看某文件变更内容
#查看未添加到暂存区的变更
git diff <文件名>
#查看已添加到暂存区的变更
git diff --cached <文件名>
#查看与上个版本的差异(无论是否添加到暂存区)
git diff <分支名> <文件名>
  • 回退某文件的所有变更
git checkout <文件>
#例如:
git checkout -- build-test.sh#注意:对于已经添加到暂存区的文件,需要先移出暂存区后再进行checkout回退
  • 将文件添加到git暂存区
git add <文件或文件夹>
#例如:git add build-test.sh
  • 文件添加到git暂存区后,想将其从暂存区中移出(撤销git add操作)
git reset <分支名> <文件名>
#例如: git reset HEAD build-test.sh
  • 提交到版本库
git commit <文件名或为空> -m "提交描述信息"
#例如:
git commit build-test.sh -m "提交build-test.sh,无需git add也能提交"
git commit -m "提交暂存区的所有文件"   
git commit -a -m "提交所有变更文件"
  • 取消某文件的版本追踪
git rm --cached <文件或文件夹>
#例如:
git rm -r --cached "Makefile"
git rm -r --cached "_qt-Debug/"
#注意:最后执行git commit此操作
  •  查看仓库的提交日志
git log
  •  查看某项提交详情
git show <提交节点ID>
#例如: git show 56a43568985db6b6d813c64d3p184e7cfb41fofb
  •  查看某文件的提交日志
git log -p <文件>

Qt Creator中使用git

1、启用git插件

2、使用git插件操作本地仓库(支持git部分功能)

  • 支持版本差异对比
  • 支持日志查询
  • 支持提交操作

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 服务器数据恢复—IBM服务器raid5阵列硬盘出现坏道的数据恢复案例
  • 服务器上部署服务
  • Revite二次开发_使用WPF和WebView2制作一个访问网站的窗口
  • pygame游戏开发系列教程(1)
  • C++数组入门
  • Python知识点:如何使用Boto3进行AWS服务管理
  • Electron 集成 Express + p-limit + SQlite WAL读写模式解决并发锁库的问题
  • OpenCV Python 图像处理入门
  • 11.怎么做好一个动态标签页
  • 设计模式21-组合模式
  • P37-数据存储
  • 数据可视化:解锁数据奥秘的钥匙与实战指南
  • 力扣每日一题 特殊数组 II 前缀和
  • 分析 avformat_open_input 数据读取过程
  • 软件需求设计分析报告(Word原件)
  • [分享]iOS开发-关于在xcode中引用文件夹右边出现问号的解决办法
  • CODING 缺陷管理功能正式开始公测
  • Computed property XXX was assigned to but it has no setter
  • java中具有继承关系的类及其对象初始化顺序
  • Vim 折腾记
  • VUE es6技巧写法(持续更新中~~~)
  • 表单中readonly的input等标签,禁止光标进入(focus)的几种方式
  • 初识MongoDB分片
  • 从@property说起(二)当我们写下@property (nonatomic, weak) id obj时,我们究竟写了什么...
  • 从伪并行的 Python 多线程说起
  • 紧急通知:《观止-微软》请在经管柜购买!
  • 开放才能进步!Angular和Wijmo一起走过的日子
  • 写给高年级小学生看的《Bash 指南》
  • 用 Swift 编写面向协议的视图
  • ​secrets --- 生成管理密码的安全随机数​
  • # 透过事物看本质的能力怎么培养?
  • # 移动硬盘误操作制作为启动盘数据恢复问题
  • (13)Hive调优——动态分区导致的小文件问题
  • (2)Java 简介
  • (Redis使用系列) Springboot 整合Redisson 实现分布式锁 七
  • (八)Flask之app.route装饰器函数的参数
  • (二)c52学习之旅-简单了解单片机
  • (贪心 + 双指针) LeetCode 455. 分发饼干
  • (转)Oracle存储过程编写经验和优化措施
  • (转载)虚幻引擎3--【UnrealScript教程】章节一:20.location和rotation
  • ***监测系统的构建(chkrootkit )
  • ./include/caffe/util/cudnn.hpp: In function ‘const char* cudnnGetErrorString(cudnnStatus_t)’: ./incl
  • .net 8 发布了,试下微软最近强推的MAUI
  • .Net Core webapi RestFul 统一接口数据返回格式
  • .NET Core中Emit的使用
  • .NET 中的轻量级线程安全
  • .netcore 获取appsettings
  • .net知识和学习方法系列(二十一)CLR-枚举
  • /proc/interrupts 和 /proc/stat 查看中断的情况
  • @staticmethod和@classmethod的作用与区别
  • [ vulhub漏洞复现篇 ] AppWeb认证绕过漏洞(CVE-2018-8715)
  • [AI]文心一言出圈的同时,NLP处理下的ChatGPT-4.5最新资讯
  • [BT]小迪安全2023学习笔记(第29天:Web攻防-SQL注入)
  • [C#][DevPress]事件委托的使用
  • [C#]winform部署yolov9的onnx模型