当前位置:首页 » 《随便一记》 » 正文

Linux git安装与部署

9 人参与  2024年10月04日 13:20  分类 : 《随便一记》  评论

点击全文阅读


目录

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.xmlTestResult.xml# Build Results of an ATL Project[Dd]ebugPS/[Rr]eleasePS/dlldata.c# DNXproject.lock.jsonartifacts/*_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 filesipch/*.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-inDocProject/buildhelp/DocProject/Help/*.HxTDocProject/Help/*.HxCDocProject/Help/*.hhcDocProject/Help/*.hhkDocProject/Help/*.hhpDocProject/Help/Html2DocProject/Help/html# Click-Once directorypublish/# 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 Outputcsx/*.build.csdef# Windows Store app package directoryAppPackages/# Visual Studio cache files# files ending in .cache can be ignored*.[Cc]ache# but keep track of directories ending in .cache!*.[Cc]ache/# OthersClientBin/[Ss]tyle[Cc]op.*~$**~*.dbmdl*.dbproj.schemaview*.pfx*.publishsettingsnode_modules/orleans.codegen.cs# RIA/Silverlight projectsGenerated_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*.XMLUpgradeLog*.htm# SQL Server files*.mdf*.ldf# Business Intelligence projects*.rdl.data*.bim.layout*.bim_*.settings# Microsoft FakesFakesAssemblies/# Node.js Tools for Visual Studio.ntvs_analysis.dat# Visual Studio 6 build log*.plg# Visual Studio 6 workspace options file*.opt# LightSwitch generated filesGeneratedArtifacts/_Pvt_Extensions/ModelManifest.xmldocs/data/src/Config.ini#*.db*.opendb#*.iniMakefile.DebugMakefile.ReleaseMakefilebuild_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部分功能)

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


点击全文阅读


本文链接:http://zhangshiyu.com/post/167626.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1