柚子快報激活碼778899分享:Linux git安裝與部署
柚子快報激活碼778899分享:Linux git安裝與部署
目錄
git安裝
1、下載與安裝
2、配置git賬號信息
創(chuàng)建本地倉庫
1、創(chuàng)建本地代碼庫文件夾
2、創(chuàng)建項目代碼本地倉庫文件夾
3、進(jìn)入到projCode目錄下,創(chuàng)建git本地倉庫
4、創(chuàng)建過濾文件.gitignore
5、添加.gitignore到git暫存區(qū)
6、提交.gitignore
7、將項目代碼移動到projCode目錄下
8、將項目代碼添加git暫存區(qū)
9、提交項目代碼到倉庫中
git本地倉庫操作常用命令
查看哪些文件做了修改(與版本做對比)
查看變更摘要
查看某文件變更內(nèi)容
回退某文件的所有變更
將文件添加到git暫存區(qū)
文件添加到git暫存區(qū)后,想將其從暫存區(qū)中移出(撤銷git add操作)
提交到版本庫
取消某文件的版本追蹤
?查看倉庫的提交日志
?查看某項提交詳情
?查看某文件的提交日志
Qt Creator中使用git
1、啟用git插件
2、使用git插件操作本地倉庫(支持git部分功能)
git安裝
1、下載與安裝
sudo apt install git
2、配置git賬號信息
#設(shè)置郵箱
git config --global user.email "xxx@xxmail.com"
#設(shè)置用戶名
git config --global user.name "yourName"
創(chuàng)建本地倉庫
1、創(chuàng)建本地代碼庫文件夾
mkdir repos
2、創(chuàng)建項目代碼本地倉庫文件夾
mkdir projCode
3、進(jìn)入到projCode目錄下,創(chuàng)建git本地倉庫
git init
4、創(chuàng)建過濾文件.gitignore
.gitignore內(nèi)容可參考如下:
## 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.xml
docs/
data/
src/Config.ini
#*.db
*.opendb
#*.ini
Makefile.Debug
Makefile.Release
Makefile
build_log.txt
5、添加.gitignore到git暫存區(qū)
git add .gitignore
6、提交.gitignore
git commit -m "上傳過濾文件.gitignore"
7、將項目代碼移動到projCode目錄下
命令:mv 原目錄 新目錄
#文件結(jié)構(gòu)如下:
$ tree ./repos -a -L 2
./repos
└── projCode
├── testProject
├── .git
└── .gitignore
3 directories, 1 file
8、將項目代碼添加git暫存區(qū)
git add .
9、提交項目代碼到倉庫中
git commit -m "提交項目代碼"
git本地倉庫操作常用命令
查看哪些文件做了修改(與版本做對比)
git status
查看變更摘要
#顯示未添加到暫存區(qū)的變更摘要
git diff --stat
#顯示已添加到暫存區(qū)的變更摘要
git diff --cached --stat
查看某文件變更內(nèi)容
#查看未添加到暫存區(qū)的變更
git diff <文件名>
#查看已添加到暫存區(qū)的變更
git diff --cached <文件名>
#查看與上個版本的差異(無論是否添加到暫存區(qū))
git diff <分支名> <文件名>
回退某文件的所有變更
git checkout <文件>
#例如:
git checkout -- build-test.sh
#注意:對于已經(jīng)添加到暫存區(qū)的文件,需要先移出暫存區(qū)后再進(jìn)行checkout回退
將文件添加到git暫存區(qū)
git add <文件或文件夾>
#例如:git add build-test.sh
文件添加到git暫存區(qū)后,想將其從暫存區(qū)中移出(撤銷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 "提交暫存區(qū)的所有文件"
git commit -a -m "提交所有變更文件"
取消某文件的版本追蹤
git rm --cached <文件或文件夾>
#例如:
git rm -r --cached "Makefile"
git rm -r --cached "_qt-Debug/"
#注意:最后執(zhí)行g(shù)it commit此操作
?查看倉庫的提交日志
git log
?查看某項提交詳情
git show <提交節(jié)點ID>
#例如: git show 56a43568985db6b6d813c64d3p184e7cfb41fofb
?查看某文件的提交日志
git log -p <文件>
Qt Creator中使用git
1、啟用git插件
2、使用git插件操作本地倉庫(支持git部分功能)
支持版本差異對比支持日志查詢支持提交操作
柚子快報激活碼778899分享:Linux git安裝與部署
精彩文章
本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點和立場。
轉(zhuǎn)載請注明,如有侵權(quán),聯(lián)系刪除。