diff options
Diffstat (limited to 'doc/university/training')
-rw-r--r-- | doc/university/training/topics/bisect.md | 2 | ||||
-rw-r--r-- | doc/university/training/topics/env_setup.md | 4 | ||||
-rw-r--r-- | doc/university/training/topics/getting_started.md | 25 | ||||
-rw-r--r-- | doc/university/training/topics/git_add.md | 38 | ||||
-rw-r--r-- | doc/university/training/topics/git_log.md | 35 | ||||
-rw-r--r-- | doc/university/training/topics/rollback_commits.md | 28 | ||||
-rw-r--r-- | doc/university/training/topics/stash.md | 58 | ||||
-rw-r--r-- | doc/university/training/topics/unstage.md | 27 |
8 files changed, 120 insertions, 97 deletions
diff --git a/doc/university/training/topics/bisect.md b/doc/university/training/topics/bisect.md index 2d5ab107fe6..01e93e4dcb0 100644 --- a/doc/university/training/topics/bisect.md +++ b/doc/university/training/topics/bisect.md @@ -10,7 +10,7 @@ comments: false - Find a commit that introduced a bug - Works through a process of elimination -- Specify a known good and bad revision to begin +- Specify a known good and bad revision to begin ---------- diff --git a/doc/university/training/topics/env_setup.md b/doc/university/training/topics/env_setup.md index b7bec83ed8a..bdf805711e0 100644 --- a/doc/university/training/topics/env_setup.md +++ b/doc/university/training/topics/env_setup.md @@ -16,10 +16,10 @@ comments: false - **Linux** ```bash - sudo yum install git-all + sudo yum install git-all ``` ```bash - sudo apt-get install git-all + sudo apt-get install git-all ``` ---------- diff --git a/doc/university/training/topics/getting_started.md b/doc/university/training/topics/getting_started.md index 153b45fb4da..1441e4b89b2 100644 --- a/doc/university/training/topics/getting_started.md +++ b/doc/university/training/topics/getting_started.md @@ -9,13 +9,15 @@ comments: false ## Instantiating Repositories * Create a new repository by instantiating it through -```bash -git init -``` + + ```bash + git init + ``` * Copy an existing project by cloning the repository through -```bash -git clone <url> -``` + + ```bash + git clone <url> + ``` ---------- @@ -24,17 +26,18 @@ git clone <url> * To instantiate a central repository a `--bare` flag is required. * Bare repositories don't allow file editing or committing changes. * Create a bare repo with -```bash -git init --bare project-name.git -``` + + ```bash + git init --bare project-name.git + ``` ---------- ## Instantiate workflow with clone 1. Create a project in your user namespace - - Choose to import from 'Any Repo by URL' and use - https://gitlab.com/gitlab-org/training-examples.git + - Choose to import from 'Any Repo by URL' and use + https://gitlab.com/gitlab-org/training-examples.git 2. Create a '`Workspace`' directory in your home directory. 3. Clone the '`training-examples`' project diff --git a/doc/university/training/topics/git_add.md b/doc/university/training/topics/git_add.md index 651366e0d49..b1483e725fe 100644 --- a/doc/university/training/topics/git_add.md +++ b/doc/university/training/topics/git_add.md @@ -11,27 +11,35 @@ comments: false Adds content to the index or staging area. * Adds a list of file -```bash -git add <files> -``` + + ```bash + git add <files> + ``` + * Adds all files including deleted ones -```bash -git add -A -``` + + ```bash + git add -A + ``` ---------- ## Git add continued * Add all text files in current dir -```bash -git add *.txt -``` + + ```bash + git add *.txt + ``` + * Add all text file in the project -```bash -git add "*.txt*" -``` + + ```bash + git add "*.txt*" + ``` + * Adds all files in directory -```bash -git add views/layouts/ -``` + + ```bash + git add views/layouts/ + ``` diff --git a/doc/university/training/topics/git_log.md b/doc/university/training/topics/git_log.md index f2709ae3890..3e39ea5cc9a 100644 --- a/doc/university/training/topics/git_log.md +++ b/doc/university/training/topics/git_log.md @@ -9,31 +9,36 @@ comments: false Git log lists commit history. It allows searching and filtering. * Initiate log -``` -git log -``` + + ``` + git log + ``` * Retrieve set number of records: -``` -git log -n 2 -``` + + ``` + git log -n 2 + ``` * Search commits by author. Allows user name or a regular expression. -``` -git log --author="user_name" -``` + + ``` + git log --author="user_name" + ``` ---------- * Search by comment message. -``` -git log --grep="<pattern>" -``` + + ``` + git log --grep="<pattern>" + ``` * Search by date -``` -git log --since=1.month.ago --until=3.weeks.ago -``` + + ``` + git log --since=1.month.ago --until=3.weeks.ago + ``` ---------- diff --git a/doc/university/training/topics/rollback_commits.md b/doc/university/training/topics/rollback_commits.md index 0db1d93d1dc..11cb557651f 100644 --- a/doc/university/training/topics/rollback_commits.md +++ b/doc/university/training/topics/rollback_commits.md @@ -9,26 +9,30 @@ comments: false ## Undo Commits * Undo last commit putting everything back into the staging area. -``` -git reset --soft HEAD^ -``` + + ``` + git reset --soft HEAD^ + ``` * Add files and change message with: -``` -git commit --amend -m "New Message" -``` + + ``` + git commit --amend -m "New Message" + ``` ---------- * Undo last and remove changes -``` -git reset --hard HEAD^ -``` + + ``` + git reset --hard HEAD^ + ``` * Same as last one but for two commits back -``` -git reset --hard HEAD^^ -``` + + ``` + git reset --hard HEAD^^ + ``` ** Don't reset after pushing ** diff --git a/doc/university/training/topics/stash.md b/doc/university/training/topics/stash.md index 5b27ac12f77..315ced1a196 100644 --- a/doc/university/training/topics/stash.md +++ b/doc/university/training/topics/stash.md @@ -10,50 +10,52 @@ We use git stash to store our changes when they are not ready to be committed and we need to change to a different branch. * Stash -``` -git stash save -# or -git stash -# or with a message -git stash save "this is a message to display on the list" -``` + + ``` + git stash save + # or + git stash + # or with a message + git stash save "this is a message to display on the list" + ``` * Apply stash to keep working on it -``` -git stash apply -# or apply a specific one from out stack -git stash apply stash@{3} -``` + + ``` + git stash apply + # or apply a specific one from out stack + git stash apply stash@{3} + ``` ---------- * Every time we save a stash it gets stacked so by using list we can see all our stashes. -``` -git stash list -# or for more information (log methods) -git stash list --stat -``` + ``` + git stash list + # or for more information (log methods) + git stash list --stat + ``` * To clean our stack we need to manually remove them. -``` -# drop top stash -git stash drop -# or -git stash drop <name> -# to clear all history we can use -git stash clear -``` + ``` + # drop top stash + git stash drop + # or + git stash drop <name> + # to clear all history we can use + git stash clear + ``` ---------- * Apply and drop on one command -``` - git stash pop -``` + ``` + git stash pop + ``` * If we meet conflicts we need to either reset or commit our changes. diff --git a/doc/university/training/topics/unstage.md b/doc/university/training/topics/unstage.md index fc72949ade9..ee7913637b9 100644 --- a/doc/university/training/topics/unstage.md +++ b/doc/university/training/topics/unstage.md @@ -10,26 +10,27 @@ comments: false * To remove files from stage use reset HEAD. Where HEAD is the last commit of the current branch. -```bash -git reset HEAD <file> -``` + ```bash + git reset HEAD <file> + ``` * This will unstage the file but maintain the modifications. To revert the file back to the state it was in before the changes we can use: -```bash -git checkout -- <file> -``` + ```bash + git checkout -- <file> + ``` ---------- * To remove a file from disk and repo use 'git rm' and to rm a dir use the '-r' flag. -``` -git rm '*.txt' -git rm -r <dirname> -``` + ``` + git rm '*.txt' + git rm -r <dirname> + ``` * If we want to remove a file from the repository but keep it on disk, say we forgot to add it to our `.gitignore` file then use `--cache`. -``` -git rm <filename> --cache -``` + + ``` + git rm <filename> --cache + ``` |