From 9a956b80adc3c773f563627501d195f8aa1794a4 Mon Sep 17 00:00:00 2001 From: vl4dd Date: Sat, 3 Apr 2021 10:58:27 +0200 Subject: [PATCH] Creating a general project for all topics of the Sys Admins Training --- exercice.md => Git/exercice.md | 0 {img => Git/img}/Branching.png | Bin {img => Git/img}/Git_Guide.png | Bin {img => Git/img}/Git_System.png | Bin {img => Git/img}/Remote_execution.png | Bin {img => Git/img}/git_log.PNG | Bin {img => Git/img}/image.jpg | Bin {img => Git/img}/tig.PNG | Bin Git/readme.md | 259 ++++++++++++++++++++++++ readme.md | 271 ++------------------------ 10 files changed, 271 insertions(+), 259 deletions(-) rename exercice.md => Git/exercice.md (100%) rename {img => Git/img}/Branching.png (100%) rename {img => Git/img}/Git_Guide.png (100%) rename {img => Git/img}/Git_System.png (100%) rename {img => Git/img}/Remote_execution.png (100%) rename {img => Git/img}/git_log.PNG (100%) rename {img => Git/img}/image.jpg (100%) rename {img => Git/img}/tig.PNG (100%) create mode 100644 Git/readme.md diff --git a/exercice.md b/Git/exercice.md similarity index 100% rename from exercice.md rename to Git/exercice.md diff --git a/img/Branching.png b/Git/img/Branching.png similarity index 100% rename from img/Branching.png rename to Git/img/Branching.png diff --git a/img/Git_Guide.png b/Git/img/Git_Guide.png similarity index 100% rename from img/Git_Guide.png rename to Git/img/Git_Guide.png diff --git a/img/Git_System.png b/Git/img/Git_System.png similarity index 100% rename from img/Git_System.png rename to Git/img/Git_System.png diff --git a/img/Remote_execution.png b/Git/img/Remote_execution.png similarity index 100% rename from img/Remote_execution.png rename to Git/img/Remote_execution.png diff --git a/img/git_log.PNG b/Git/img/git_log.PNG similarity index 100% rename from img/git_log.PNG rename to Git/img/git_log.PNG diff --git a/img/image.jpg b/Git/img/image.jpg similarity index 100% rename from img/image.jpg rename to Git/img/image.jpg diff --git a/img/tig.PNG b/Git/img/tig.PNG similarity index 100% rename from img/tig.PNG rename to Git/img/tig.PNG diff --git a/Git/readme.md b/Git/readme.md new file mode 100644 index 0000000..c4d668f --- /dev/null +++ b/Git/readme.md @@ -0,0 +1,259 @@ +# Git + +![GitHub Logo](img/image.jpg) + +## Usefull links +[Git Cheat Sheet](https://education.github.com/git-cheat-sheet-education.pdf) + + +## Git System +![Git System](img/Git_Guide.png) + +## Remote Execution +![Remote Execution](img/Remote_execution.png) + + +## Basic commands +================= + +### Initialize an existing directory as a Git repository +```bash +$ git init +Initialized empty Git repository in C:/Users/Admin/Documents/Git/.git/ +``` +### Show modified files in working directory, staged for your next commit + +```bash +$ git status +On branch master + +No commits yet + +Untracked files: + (use "git add ..." to include in what will be committed) + Readme.md + image.jpg + +nothing added to commit but untracked files present (use "git add" to track) +``` +### Add a file as it looks now to your next commit (stage) +```bash +$ git add Readme.md image.jpg +``` +### Commit your staged content as a new commit snapshot +```bash +$ git commit -m "First Commit" +[master (root-commit) 784ae2e] First Commit + Committer: unknown +Your name and email address were configured automatically based +on your username and hostname. Please check that they are accurate. +You can suppress this message by setting them explicitly: + + git config --global user.name "Your Name" + git config --global user.email you@example.com + +After doing this, you may fix the identity used for this commit with: + + git commit --amend --reset-author + + 2 files changed, 61 insertions(+) + create mode 100644 Readme.md + create mode 100644 image.jpg +``` + +### Set a name & email that is identifiable for credit when review version history +```bash +$ git config --global user.name “[firstname lastname]” + +$ git config --global user.email “[valid-email]” +``` + +### Show all commits in the current branch’s history +```bash +$ git log +commit 784ae2e2d10720c23eb7cebdf8386ef2157fe628 (HEAD -> master) +Author: unknown +Date: Thu Apr 1 12:11:34 2021 +0200 + + First Commit +``` + +### tig vs git log --graph + +Tig allows you to browse changes in a Git repository and can additionally act as a pager for output of various Git commands. When used as a pager, it will display input from stdin and colorize it. + +When browsing repositories, Tig uses the underlying Git commands to present the user with various views, such as summarized commit log and showing the commit with the log message, diffstat, and the diff. + +> $ tig + +## tig +![tig](img/tig.PNG) + +> $ git log --graph + +## git log +![git log](img/git_log.PNG) + + +## SHARE & UPDATE +### Retrieving updates from another repository and updating local repos +================================= + +add a git URL as an alias + +>git remote add [alias] [url] + +fetch down all the branches from that Git remote + +>git fetch [alias] + +merge a remote branch into your current branch to bring it up to date +>git merge [alias]/[branch] + + +Transmit local branch commits to the remote repository branch + +>git push [alias] [branch] + +>git pull + +fetch and merge any commits from the tracking remote branch + + +## BRANCH & MERGE +### Isolating work in branches, changing context, and integrating changes + +![Remote Execution](img/Branching.png) + +>git branch + +list your branches. a * will appear next to the currently active branch + +>git branch [branch-name] + +create a new branch at the current commit + +>git checkout + +switch to another branch and check it out into your working directory + +>git checkout -b|-B [] + +Specifying -b causes a new branch to be created as if git-branch(1) were called and then checked out. + +If -B is given, is created if it doesn’t exist; otherwise, it is reset. This is the transactional equivalent of + +>git merge [branch] + +merge the specified branch’s history into the current one + +>git log + +show all commits in the current branch’s history + +## TRACKING PATH CHANGES +### Versioning file removes and path changes +================================= + +Delete the file from project and stage the removal for commit + +>git rm [file] + +Change an existing file path and stage the move + +>git mv [existing-path] [new-path] + +Show all commit logs with indication of any paths that moved + +>git log --stat -M + + +### History +```bash +history + 1 git init + 2 git status + 3 git add Readme.md image.jpg + 4 git status + 5 git commit -m "First Commit" + 6 git config --global user.name vl4dd + 7 git config --global user.email ticus@kraland.net + 8 git commit -m "First Commit" + 9 git status + 10 git log + 11 git commit -m "Second commit" + 12 git add Readme.md + 13 git commit -m "Second commit" + 14 git log +``` + +### +Checker le satus +> git status + +Ajouter un element dans la branche +> git add Readme.md + +Commit les changement +> git commit -m "First commit" + +Show all commit +>git checkout + +Merge +>git merge + +## Setup + +### Configuring user information used across all local repositories + +>git config --global user.name “[firstname lastname]” + +set a name that is identifiable for credit when review version history + +>git config --global user.email “[valid-email]” + +set an email address that will be associated with each history marker + +>git config --global color.ui auto + +set automatic command line coloring for Git for easy reviewing + +### Saving your uncommitted work for a quick fix then getting it back + +>git stash + +temporarily stash your work since your last commit + +>git stash pop + +fetch your stashed work to continue it + +$ git stash pop stash@{2} + +in case you want to apply a specific Stash item (not the most recent one), you can provide the index name of that item in the "pop" option + +### Rewriting history + +>git commit --amend -m "New commit message" + +replace the last commit + +>git commit --amend --no-edit + +replace the last commit without changing the commit message + +>git rebase -i {branch} + +take the precedent commit and add it to your branch + +### Ignoring files + +>touch .gitignore && echo {what you want to ignore} >> .gitignore + +create a file and specify what (extensions, directories, files) to ignore in it + +>git rm --cached {fileignored} + +remove from the tracking index a file that should be ignored but wasnt because already tracked when the ignore rule was created + diff --git a/readme.md b/readme.md index c4d668f..cf4092d 100644 --- a/readme.md +++ b/readme.md @@ -1,259 +1,12 @@ -# Git - -![GitHub Logo](img/image.jpg) - -## Usefull links -[Git Cheat Sheet](https://education.github.com/git-cheat-sheet-education.pdf) - - -## Git System -![Git System](img/Git_Guide.png) - -## Remote Execution -![Remote Execution](img/Remote_execution.png) - - -## Basic commands -================= - -### Initialize an existing directory as a Git repository -```bash -$ git init -Initialized empty Git repository in C:/Users/Admin/Documents/Git/.git/ -``` -### Show modified files in working directory, staged for your next commit - -```bash -$ git status -On branch master - -No commits yet - -Untracked files: - (use "git add ..." to include in what will be committed) - Readme.md - image.jpg - -nothing added to commit but untracked files present (use "git add" to track) -``` -### Add a file as it looks now to your next commit (stage) -```bash -$ git add Readme.md image.jpg -``` -### Commit your staged content as a new commit snapshot -```bash -$ git commit -m "First Commit" -[master (root-commit) 784ae2e] First Commit - Committer: unknown -Your name and email address were configured automatically based -on your username and hostname. Please check that they are accurate. -You can suppress this message by setting them explicitly: - - git config --global user.name "Your Name" - git config --global user.email you@example.com - -After doing this, you may fix the identity used for this commit with: - - git commit --amend --reset-author - - 2 files changed, 61 insertions(+) - create mode 100644 Readme.md - create mode 100644 image.jpg -``` - -### Set a name & email that is identifiable for credit when review version history -```bash -$ git config --global user.name “[firstname lastname]” - -$ git config --global user.email “[valid-email]” -``` - -### Show all commits in the current branch’s history -```bash -$ git log -commit 784ae2e2d10720c23eb7cebdf8386ef2157fe628 (HEAD -> master) -Author: unknown -Date: Thu Apr 1 12:11:34 2021 +0200 - - First Commit -``` - -### tig vs git log --graph - -Tig allows you to browse changes in a Git repository and can additionally act as a pager for output of various Git commands. When used as a pager, it will display input from stdin and colorize it. - -When browsing repositories, Tig uses the underlying Git commands to present the user with various views, such as summarized commit log and showing the commit with the log message, diffstat, and the diff. - -> $ tig - -## tig -![tig](img/tig.PNG) - -> $ git log --graph - -## git log -![git log](img/git_log.PNG) - - -## SHARE & UPDATE -### Retrieving updates from another repository and updating local repos -================================= - -add a git URL as an alias - ->git remote add [alias] [url] - -fetch down all the branches from that Git remote - ->git fetch [alias] - -merge a remote branch into your current branch to bring it up to date ->git merge [alias]/[branch] - - -Transmit local branch commits to the remote repository branch - ->git push [alias] [branch] - ->git pull - -fetch and merge any commits from the tracking remote branch - - -## BRANCH & MERGE -### Isolating work in branches, changing context, and integrating changes - -![Remote Execution](img/Branching.png) - ->git branch - -list your branches. a * will appear next to the currently active branch - ->git branch [branch-name] - -create a new branch at the current commit - ->git checkout - -switch to another branch and check it out into your working directory - ->git checkout -b|-B [] - -Specifying -b causes a new branch to be created as if git-branch(1) were called and then checked out. - -If -B is given, is created if it doesn’t exist; otherwise, it is reset. This is the transactional equivalent of - ->git merge [branch] - -merge the specified branch’s history into the current one - ->git log - -show all commits in the current branch’s history - -## TRACKING PATH CHANGES -### Versioning file removes and path changes -================================= - -Delete the file from project and stage the removal for commit - ->git rm [file] - -Change an existing file path and stage the move - ->git mv [existing-path] [new-path] - -Show all commit logs with indication of any paths that moved - ->git log --stat -M - - -### History -```bash -history - 1 git init - 2 git status - 3 git add Readme.md image.jpg - 4 git status - 5 git commit -m "First Commit" - 6 git config --global user.name vl4dd - 7 git config --global user.email ticus@kraland.net - 8 git commit -m "First Commit" - 9 git status - 10 git log - 11 git commit -m "Second commit" - 12 git add Readme.md - 13 git commit -m "Second commit" - 14 git log -``` - -### -Checker le satus -> git status - -Ajouter un element dans la branche -> git add Readme.md - -Commit les changement -> git commit -m "First commit" - -Show all commit ->git checkout - -Merge ->git merge - -## Setup - -### Configuring user information used across all local repositories - ->git config --global user.name “[firstname lastname]” - -set a name that is identifiable for credit when review version history - ->git config --global user.email “[valid-email]” - -set an email address that will be associated with each history marker - ->git config --global color.ui auto - -set automatic command line coloring for Git for easy reviewing - -### Saving your uncommitted work for a quick fix then getting it back - ->git stash - -temporarily stash your work since your last commit - ->git stash pop - -fetch your stashed work to continue it - -$ git stash pop stash@{2} - -in case you want to apply a specific Stash item (not the most recent one), you can provide the index name of that item in the "pop" option - -### Rewriting history - ->git commit --amend -m "New commit message" - -replace the last commit - ->git commit --amend --no-edit - -replace the last commit without changing the commit message - ->git rebase -i {branch} - -take the precedent commit and add it to your branch - -### Ignoring files - ->touch .gitignore && echo {what you want to ignore} >> .gitignore - -create a file and specify what (extensions, directories, files) to ignore in it - ->git rm --cached {fileignored} - -remove from the tracking index a file that should be ignored but wasnt because already tracked when the ignore rule was created - +# LinuxSysAdminsDoc + +## Description +Shared documentation for the brussels formation Linux Sys Admins group. +feel free to modify :) + +## Topics +### Git +- Cheat sheet +the basic Git commands to help you learn Git, and more advanced concepts around Git branches, remote repositories, undoing changes, and more. +- [Git Exercices](https://gitexercises.fracz.com/) +Online platform to learn and practice Git. Discover its features you might haven't been aware of. With all the exercises provided you will rapidly become a Git Master!