±à¼ÍƼö: |
±¾ÎÄÖ÷Òª½éÉÜÁËDevopsÊÇʲô£¿DevopsÄܸÉÂDevopsÈçºÎʵÏÖ£¿Git°æ±¾¿ØÖÆÏµÍ³¼ò½é£¬ÎªÊ²Ã´ÐèÒª°æ±¾¿ØÖÆÏµÍ³£¬³£¼û°æ±¾¹ÜÀí¹¤¾ß£¬Git°²×°ÒÔ¼°Git³£¹æÊ¹Óá£
±¾ÎÄÀ´×ÔÓÚwww.abins.cn£¬ÓÉ»ðÁú¹ûÈí¼þAlice±à¼¡¢ÍƼö¡£ |
|
1.Devops½éÉÜ 01.DevopsÊÇʲô

¿ª·¢£ºdevelopment
ÔËά£ºoperations
02.DevopsÄܸÉÂï
Ìá¸ß²úÆ·ÖÊÁ¿
01.×Ô¶¯»¯²âÊÔ
02.³ÖÐø¼¯³É
03.´úÂëÖÊÁ¿¹ÜÀí¹¤¾ß
04.³ÌÐòÔ±¹ÄÀøÊ¦
03.DevopsÈçºÎʵÏÖ
¼ÈÈ»ÕâôºÃ£¿ÎªÊ²Ã´ÓÐЩ¹«Ë¾Ã»ÓÐ
Éè¼Æ¼Ü¹¹¹æ»®-´úÂëµÄ´æ´¢-¹¹½¨-²âÊÔ¡¢Ô¤Éú²ú¡¢²¿Êð¡¢¼à¿Ø
2.Git°æ±¾¿ØÖÆÏµÍ³
01.°æ±¾¿ØÖÆÏµÍ³¼ò½é
vcs `version control system`
°æ±¾¿ØÖÆÏµÍ³ÊÇÒ»ÖּǼһ¸ö»òÈô¸É¸öÎļþÄÚÈݱ仯£¬ÒԱ㽫À´²éÔÄÌØ¶¨°æ±¾ÄÚÈÝÇé¿öµÄϵͳ
¼Ç¼ÎļþµÄËùÓÐÀúÊ·±ä»¯
ËæÊ±¿É»Ö¸´µ½ÈκÎÒ»¸öÀúʷ״̬
¶àÈËÐ×÷¿ª·¢
02.ΪʲôÐèÒª°æ±¾¿ØÖÆÏµÍ³

03.³£¼û°æ±¾¹ÜÀí¹¤¾ß 
SVN
¼¯ÖÐʽµÄ°æ±¾¿ØÖÆÏµÍ³£¬Ö»ÓÐÒ»¸öÖÐÑëÊý¾Ý²Ö¿â£¬Èç¹ûÖÐÑëÊý¾Ý²Ö¿â¹ÒÁË»òÕß²»¿É·ÃÎÊ£¬ËùÓеÄʹÓÃÕßÎÞ·¨Ê¹ÓÃSVN£¬ÎÞ·¨½øÐÐÌá½»»ò±¸·ÝÎļþ¡£
Git
·Ö²¼Ê½µÄ°æ±¾¿ØÖÆÏµÍ³£¬ÔÚÿ¸öʹÓÃÕßµçÄÔÉϾÍÓÐÒ»¸öÍêÕûµÄÊý¾Ý²Ö¿â£¬Ã»ÓÐÍøÂçÒÀÈ»¿ÉÒÔʹÓÃGit£¬µ±È»ÎªÁËϰ¹ß¼°ÍŶÓÐ×÷£¬»á½«±¾µØÊý¾Ýͬ²½µ½Git·þÎñÆ÷»òÕßGithubµÈ´úÂë²Ö¿â¡£
04.Å£±ÆµÄÈ˲»ÐèÒª½âÊÍÕâ¾ä»°±»LINUXÕ¹ÏÖµÄÁÜÀ쾡Ö 
ÄêÇáʱµÄÍÐÍß×È
3.Git°²×°
01.ϵͳ»·¾³×¼±¸
[root@git ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@git ~]# uname -r #²é¿´Äں˰汾ÐÅÏ¢
3.10.0-862.el7.x86_64
[root@git ~]# getenforce #È·ÈÏSelinuxÊÇ·ñ¹Ø±Õ
Disabled
[root@git ~]# systemctl stop firewalld
02.Git²¿Êð°²×°
[root@git ~]# yum install -y git
[root@git ~]# rpm -qa git #¼ì²éÊÇ·ñ°²×°³É¹¦
git-1.8.3.1-23.el7_8.x86_64
[root@git ~]# git config
--global ʹÓÃÈ«¾ÖÅäÖÃÎļþ
--system ʹÓÃϵͳ¼¶ÅäÖÃÎļþ
--local ʹÓð汾¿â¼¶ÅäÖÃÎļþ
[root@git ~]# git config --global
user.name "abin" #ÅäÖÃgitʹÓÃÓû§
[root@git ~]# git config --global
user.email "abin@mail.com" #ÅäÖÃgitʹÓÃÓÊÏä
[root@git ~]# git config --global
color.ui true #Óï·¨¸ßÁÁ
[root@git ~]# git config --list
user.name=abin
user.email=abin@mail.com
color.ui=true
03.Git³õʼ»¯
³õʼ»¯¹¤×÷Ŀ¼£¬¶ÔÒÑ´æÔÚµÄĿ¼»òÕß¶ÔÒÑ´æÔÚµÄĿ¼¶¼¿É½øÐгõʼ»¯
mkdir git_data
cd git_data/
#³õʼ»¯
git init
[root@git ~/git_data]# ll -a
total 4
drwxr-xr-x 3 root root 18 Jul 2 18:32 .
dr-xr-x---. 7 root root 4096 Jul 2 18:32 ..
drwxr-xr-x 7 root root 119 Jul 2 18:32 .git #ÓдËĿ¼˵Ã÷ÒѾÊDzֿâ
#²é¿´¹¤×÷Çø×´Ì¬
git status
Òþ²ØÎļþ½éÉÜ£º
branches #·Ö֧Ŀ¼
config #¶¨ÒåÏîÄ¿ÌØÓеÄÅäÖÃÑ¡Ïî
description #½ö¹©git web³ÌÐòʹÓÃ
HEAD #ָʾµ±Ç°·ÖÖ§
hooks #°üº¬git¹³×ÓÎļþ
info #°üº¬Ò»¸öÈ«¾ÖÅųýÎļþ£¨excludeÎļþ£©
objects #´æ·ÅËùÓÐÊý¾ÝÄÚÈÝ£¬ÓÐinfoºÍpackÁ½¸ö×ÓÎļþ¼Ð
refs #´æ·ÅÖ¸ÏòÊý¾Ý£¨·ÖÖ§£©µÄÌá½»¶ÔÏóµÄÖ¸Õë
index #±£´æÔÝ´æÇøÐÅÏ¢£¬ÔÚÖ´ÐÐgit initµÄʱºò£¬Õâ¸öÎļþ»¹Ã»ÓÐ
[root@git ~/git_data]# tree .git --git_data/¹¤×÷Ŀ¼
.git
©À©¤©¤ branches
©À©¤©¤ config
©À©¤©¤ description
©À©¤©¤ HEAD
©À©¤©¤ hooks
©¦ ©À©¤©¤ applypatch-msg.sample
©¦ ©À©¤©¤ commit-msg.sample
©¦ ©À©¤©¤ post-update.sample
©¦ ©À©¤©¤ pre-applypatch.sample
©¦ ©À©¤©¤ pre-commit.sample
©¦ ©À©¤©¤ prepare-commit-msg.sample
©¦ ©À©¤©¤ pre-push.sample
©¦ ©À©¤©¤ pre-rebase.sample
©¦ ©¸©¤©¤ update.sample
©À©¤©¤ info
©¦ ©¸©¤©¤ exclude
©À©¤©¤ objects --±¾µØ²Ö¿â
©¦ ©À©¤©¤ info
©¦ ©¸©¤©¤ pack
©¸©¤©¤ refs --ÔÝ´æÇø
©À©¤©¤ heads --Í·²¿
©¸©¤©¤ tags --Ö¸Õë±êÇ©
9 directories, 13 files
Êý¾Ý±£´æµ½±¾µØ²Ö¿âǰҪ¾¹ýÔÝ´æÇø |
4.Git³£¹æÊ¹ÓÃ
01.´´½¨Êý¾Ý-Ìá½»Êý¾Ý 
02.ËÄÖÖ״̬ 
03.git»ù´¡ÃüÁî
[root@git ~/git_data]# git status --²é¿´¹¤×÷Çø×´Ì¬
# λÓÚ·ÖÖ§ master
# ³õʼÌá½»
ÎÞÎļþÒªÌá½»£¨´´½¨/¿½±´Îļþ²¢Ê¹ÓÃ"git add" ½¨Á¢¸ú×Ù£©
[root@git ~/git_data]# git status
# On branch master --λÓÚ·ÖÖ§ master
#
# Initial commit --³õʼÌá½»
#
# Untracked files: --δ¸ú×ÙµÄÎļþ
# (use "git add <file>..." to
include in what will be committed)
# --£¨Ê¹ÓÃ"git add <file>..."ÒÔ°üº¬ÒªÌá½»µÄÄÚÈÝ£©
# a
# b
# c
nothing added to commit but untracked files present
(use "git add" to track) --ʹÓÃgit add½øÐиú×Ù |
½«ÎļþÌí¼Óµ½ÔÝ´æÇø
[root@git ~/git_data]#
git add a --½«aÎļþÌá½»µ½ÔÝ´æÇø
[root@git ~/git_data]# tree .git
.git
©À©¤©¤ branches
©À©¤©¤ config
©À©¤©¤ description
©À©¤©¤ HEAD
©À©¤©¤ hooks
©¦ ©À©¤©¤ applypatch-msg.sample
©¦ ©À©¤©¤ commit-msg.sample
©¦ ©À©¤©¤ post-update.sample
©¦ ©À©¤©¤ pre-applypatch.sample
©¦ ©À©¤©¤ pre-commit.sample
©¦ ©À©¤©¤ prepare-commit-msg.sample
©¦ ©À©¤©¤ pre-push.sample
©¦ ©À©¤©¤ pre-rebase.sample
©¦ ©¸©¤©¤ update.sample
©À©¤©¤ index --Ìá½»µ½ÔÝ´æÇøÒÔºó³öÏÖindexÎļþ
©À©¤©¤ info
©¦ ©¸©¤©¤ exclude
©À©¤©¤ objects
©¦ ©À©¤©¤ e6
©¦ ©¦ ©¸©¤©¤ 9de29bb2d1d6434b8b29ae775ad8c2e48c5391
©¦ ©À©¤©¤ info
©¦ ©¸©¤©¤ pack
©¸©¤©¤ refs
©À©¤©¤ heads
©¸©¤©¤ tags
10 directories, 15 files
[root@git ~/git_data]# git status
# On branch master #λÓÚ·ÖÖ§ master
#
# Initial commit #³õʼÌá½»
#
# Changes to be committed: #ÒªÌá½»µÄ±ä¸ü
# (use "git rm --cached <file>..."
to unstage) #³·³öÔÝ´æÇø
#
# new file: a
#
# Untracked files:
# (use "git add <file>..." to
include in what will be committed)
#
# b
# c |
´ÓÔÝ´æÇø³·³öÎļþ
[root@git ~/git_data]#
git add a --½«aÎļþÌá½»µ½ÔÝ´æÇø
[root@git ~/git_data]# tree .git
.git
©À©¤©¤ branches
©À©¤©¤ config
©À©¤©¤ description
©À©¤©¤ HEAD
©À©¤©¤ hooks
©¦ ©À©¤©¤ applypatch-msg.sample
©¦ ©À©¤©¤ commit-msg.sample
©¦ ©À©¤©¤ post-update.sample
©¦ ©À©¤©¤ pre-applypatch.sample
©¦ ©À©¤©¤ pre-commit.sample
©¦ ©À©¤©¤ prepare-commit-msg.sample
©¦ ©À©¤©¤ pre-push.sample
©¦ ©À©¤©¤ pre-rebase.sample
©¦ ©¸©¤©¤ update.sample
©À©¤©¤ index --Ìá½»µ½ÔÝ´æÇøÒÔºó³öÏÖindexÎļþ
©À©¤©¤ info
©¦ ©¸©¤©¤ exclude
©À©¤©¤ objects
©¦ ©À©¤©¤ e6
©¦ ©¦ ©¸©¤©¤ 9de29bb2d1d6434b8b29ae775ad8c2e48c5391
©¦ ©À©¤©¤ info
©¦ ©¸©¤©¤ pack
©¸©¤©¤ refs
©À©¤©¤ heads
©¸©¤©¤ tags
10 directories, 15 files
[root@git ~/git_data]# git status
# On branch master #λÓÚ·ÖÖ§ master
#
# Initial commit #³õʼÌá½»
#
# Changes to be committed: #ÒªÌá½»µÄ±ä¸ü
# (use "git rm --cached <file>..."
to unstage) #³·³öÔÝ´æÇø
#
# new file: a
#
# Untracked files:
# (use "git add <file>..." to
include in what will be committed)
#
# b
# c |
ɾ³ýÎļþ
1.ÏÈ´ÓÔÝ´æÇø³·»Øµ½¹¤×÷Çø¡¢È»ºóÖ±½Óɾ³ýÎļþ
git rm --cached c
rm -f c
2.Ö±½Ó´ÓÔÝ´æÇøÓòͬ¹¤×÷ÇøÓòһͬɾ³ýÎļþÃüÁî
git rm -f b
[root@git ~/git_data]# git commit -m "commit
a" #Ìá½»µ½±¾µØ²Ö¿â
[master (root-commit) 385b062] commit a
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a
create mode 100644 b
[root@git ~/git_data]# git status
# On branch master #λÓÚ·ÖÖ§ master
# Untracked files: #ÎÞÎļþÒªÌá½»£¬¸É¾»µÄ¹¤×÷Çø
# (use "git add <file>..." to
include in what will be committed)
#
# c
nothing added to commit but untracked files present
(use "git add" to track)
[root@git ~/git_data]# |
|