DevOps Tools/SCM/Git

From r00tedvw.com wiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
[[DevOps_Tools\Overview|Overview]] | [[DevOps_Tools\SCM|Source Control Management (SCM)]]<br>
+
[[DevOps_Tools/Overview|Overview]] | [[DevOps_Tools/CI|Continuous Integration (CI)]] | [[DevOps_Tools/SCM|Source Control Management (SCM)]] | [[DevOps_Tools/Containerization|Containerization]] | [[DevOps_Tools/Configuration|Configuration]]
[[DevOps_Tools\SCM\Git|Git]]
+
=[[DevOps_Tools\SCM\Git|Git]]=
=Install and Configure=
+
==Install and Configure==
 
Done on CentOS 7.  Serves as an agentless server and client.  You can use this package to create a local repository as well as other git functions.
 
Done on CentOS 7.  Serves as an agentless server and client.  You can use this package to create a local repository as well as other git functions.
 
  <nowiki>~$ yum install git</nowiki>
 
  <nowiki>~$ yum install git</nowiki>
Line 8: Line 8:
 
~$ sudo git config --global user.email "email address"
 
~$ sudo git config --global user.email "email address"
 
~$ sudo git config --system core.editor "/bin/vim"</nowiki>
 
~$ sudo git config --system core.editor "/bin/vim"</nowiki>
=Initializing Local Repo=
+
==Initializing Local Repo==
 
Create a local directory with nothing in it.  This is called initializing the repository
 
Create a local directory with nothing in it.  This is called initializing the repository
 
  <nowiki>~$ mkdir ~/repo
 
  <nowiki>~$ mkdir ~/repo
Line 16: Line 16:
 
  <nowiki>~$ git config user.name "user"
 
  <nowiki>~$ git config user.name "user"
 
~$ git config user.email "[email protected]"</nowiki>
 
~$ git config user.email "[email protected]"</nowiki>
=Basics=
+
==Basics==
==add==
+
===add===
 
adds a new file to the repo.
 
adds a new file to the repo.
 
  <nowiki>~$ git add filename
 
  <nowiki>~$ git add filename
Line 23: Line 23:
 
~$ git add .    ---- adds everything in the current directory
 
~$ git add .    ---- adds everything in the current directory
 
</nowiki>
 
</nowiki>
==status==
+
===status===
 
shows the current status of the git repository
 
shows the current status of the git repository
 
  <nowiki>~$ git status</nowiki>
 
  <nowiki>~$ git status</nowiki>
==commit==
+
===commit===
 
Commits the changes to the repo
 
Commits the changes to the repo
 
  <nowiki>~$ git commit -m "comment on commit"</nowiki>
 
  <nowiki>~$ git commit -m "comment on commit"</nowiki>
 
commit anything that is staged, but not anything that is untracked.
 
commit anything that is staged, but not anything that is untracked.
 
  <nowiki>~$ git commit -a</nowiki>
 
  <nowiki>~$ git commit -a</nowiki>
==delete==
+
===delete===
 
deletes a file from the git repo.  you must delete the file first.
 
deletes a file from the git repo.  you must delete the file first.
 
  <nowiki>~$ rm filename
 
  <nowiki>~$ rm filename
 
~$ git rm filename</nowiki>
 
~$ git rm filename</nowiki>
==log==
+
===log===
 
Shows you a log of all the commits and changes.
 
Shows you a log of all the commits and changes.
 
  <nowiki>~$ git log
 
  <nowiki>~$ git log
Line 44: Line 44:
 
~$ git log --graph --decorate  ------ shows a directory tree view of the changes.
 
~$ git log --graph --decorate  ------ shows a directory tree view of the changes.
 
</nowiki>
 
</nowiki>
==clone==
+
===clone===
 
Clones a git repository
 
Clones a git repository
 
  <nowiki>~$ git clone "local path"
 
  <nowiki>~$ git clone "local path"
Line 50: Line 50:
 
~$ git clone https://github.com/repository/project.git
 
~$ git clone https://github.com/repository/project.git
 
</nowiki>
 
</nowiki>
==push==
+
===push===
 
push changes to repo
 
push changes to repo
 
  <nowiki>~$ git push origin master
 
  <nowiki>~$ git push origin master
 
</nowiki>
 
</nowiki>
==ignore==
+
===ignore===
 
Ignore file types in local/specific repository
 
Ignore file types in local/specific repository
 
  <nowiki>~$ vim .gitignore
 
  <nowiki>~$ vim .gitignore
Line 61: Line 61:
 
/ignored_directory/*
 
/ignored_directory/*
 
</nowiki>
 
</nowiki>
==merge==
+
===merge===
 
merges two branches together. start by selecting the branch you want to merge another branch into.
 
merges two branches together. start by selecting the branch you want to merge another branch into.
 
  <nowiki>~$ git merge branch_name</nowiki>
 
  <nowiki>~$ git merge branch_name</nowiki>
  
=Global Settings=
+
==Global Settings==
==exclude==
+
===exclude===
 
Show excluded files
 
Show excluded files
 
  <nowiki>~$ git config --global core.excludesfile</nowiki>
 
  <nowiki>~$ git config --global core.excludesfile</nowiki>
Line 76: Line 76:
 
*.filetype</nowiki>
 
*.filetype</nowiki>
  
=Branch=
+
==Branch==
 
Determine current branch
 
Determine current branch
 
  <nowiki>~$ git branch</nowiki>
 
  <nowiki>~$ git branch</nowiki>

Revision as of 16:59, 18 December 2018

Overview | Continuous Integration (CI) | Source Control Management (SCM) | Containerization | Configuration

Contents

Git

Install and Configure

Done on CentOS 7. Serves as an agentless server and client. You can use this package to create a local repository as well as other git functions.

~$ yum install git

Setup global parameters

~$ sudo git config --global user.name "global username"
~$ sudo git config --global user.email "email address"
~$ sudo git config --system core.editor "/bin/vim"

Initializing Local Repo

Create a local directory with nothing in it. This is called initializing the repository

~$ mkdir ~/repo
~$ git init ~/repo
Initialized empty Git repository in /home/user/repo/.git/

Set repo user & email, if you want something different from the global.

~$ git config user.name "user"
~$ git config user.email "[email protected]"

Basics

add

adds a new file to the repo.

~$ git add filename
~$ git add *    ---- adds everything in the current directory
~$ git add .     ---- adds everything in the current directory

status

shows the current status of the git repository

~$ git status

commit

Commits the changes to the repo

~$ git commit -m "comment on commit"

commit anything that is staged, but not anything that is untracked.

~$ git commit -a

delete

deletes a file from the git repo. you must delete the file first.

~$ rm filename
~$ git rm filename

log

Shows you a log of all the commits and changes.

~$ git log
~$ git log --oneline       -----  shows the logs in a single line
~$ git log -p                  ----- shows details of the changes per line per log.
~$ git log --author="username"          ------- shows logs of a certain user
~$ git log --grep="search term"                 ------- shows logs of changes that match the search term
~$ git log --graph --decorate   ------ shows a directory tree view of the changes.

clone

Clones a git repository

~$ git clone "local path"
~$ git clone user@hostname:repo_directory   ---   assumes the repo directory is in the remote user's home directory.
~$ git clone https://github.com/repository/project.git

push

push changes to repo

~$ git push origin master

ignore

Ignore file types in local/specific repository

~$ vim .gitignore
#local git ignore in specific repo
*.filetype
/ignored_directory/*

merge

merges two branches together. start by selecting the branch you want to merge another branch into.

~$ git merge branch_name

Global Settings

exclude

Show excluded files

~$ git config --global core.excludesfile

Exclude file/path

~$ git config --global core.excludesfile '/etc/gitignore'

Manually ignore files via exclude file

~$ sudo vim /etc/gitignore
# globally ignore files based on type
*.filetype

Branch

Determine current branch

~$ git branch

Create new branch

~$ git branch new_branch

Select new branch

~$ git checkout branch_name

Create new branch and select at the same time

~$ git checkout -b new_branch
Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki
Confluence
DevOps Tools
Ubuntu
Ubuntu 22
Mac OSX
Oracle Linux
AWS
Windows
OpenVPN
Grafana
InfluxDB2
TrueNas
OwnCloud
Pivotal
osTicket
OTRS
phpBB
WordPress
VmWare ESXI 5.1
Crypto currencies
HTML
CSS
Python
Java Script
PHP
Raspberry Pi
Canvas LMS
Kaltura Media Server
Plex Media Server
MetaSploit
Zoneminder
ShinobiCE
Photoshop CS2
Fortinet
Uploaded
Certifications
General Info
Games
Meal Plans
NC Statutes
2020 Election
Volkswagen
Covid
NCDMV
Toolbox