Skip to content
Snippets Groups Projects
Verified Commit 4e5353e7 authored by Laurent Heirendt's avatar Laurent Heirendt :airplane:
Browse files

2nd round

parent ef141452
No related branches found
No related tags found
No related merge requests found
# Cherry-picking
* Cherry-pick allows to pick one (or more) specific commits from a list of commits.
* Cherry picking only picks the selected commit(s), not everything up to that commit.
* Cherry-picking allows to pick one (or more) specific commits from a list of commits.
* Only the chosen commit(s) are picked, not everything up to that commit.
<div style="top: 8em; left: 25%; position: absolute;">
<img src="slides/img/cherryPick.png" height=500px>
......@@ -11,8 +11,9 @@
# Example (1)
* Create and commit two files in the `develop `branch
* Create and commit two files in the `develop ` branch
```bash
$ git checkout develop
$ echo "# Venue details" > location.md
$ # add and commit the file location.md
$ echo "# Speakers" > speakers.md
......@@ -46,26 +47,37 @@ $ git push origin myBranch
# Partial chery-picking
* Partial cherry-picking allows you to unpack the changes from a commit.
* Imagine you committed many files, and you want to remove certain files.
* In practice:
- You commited all files, and you realize that there is your data inside!
- You have committed accidentally sensitive data, such as your password
- You committed hidden files, for instance `.DS_Store` files
- ...
# Example (1)
* Hard reset the `myBranch` branch:
```bash
$ git checkout myBranch
$ git reset --hard HEAD~2 # do not preserve files
```
* Reset the `develop` branch:
```bash
$ git checkout develop
$ git reset HEAD~2
$ git reset HEAD~2 # preserve files
```
* Add the `location.md` and the `speakers.md` files as 1 commit:
```bash
$ echo "# Venue details" > location.md
$ echo "# Speakers" > speakers.md
$ git add location.md speakers.md
$ git commit -m "add location and speakers files"
```
......@@ -83,7 +95,7 @@ $ git status
```
Now, remove the file `location.md`:
```bash
$ git restore --staged location.md
$ git restore --staged location.md # old version of git: $ git reset HEAD location.md
$ rm location.md
```
Commit the changes:
......
# Getting Started
# Getting Started (1)
Make sure that your git is configured properly:
```bash
......@@ -20,25 +20,29 @@ Fork and then clone the tutorial repository
$ git clone ssh://git@git-r3lab-server.uni.lu:8022/<first.last>/advanced-practice.git
```
**Note:** Please generate your SSH before with `$ ssh-keygen -t rsa` and set it in Gitlab!
Add a remote upstream
```bash
$ cd advanced-practice
# add upstream URL
$ git remote add upstream ssh://git@git-r3lab-server.uni.lu:8022/R3/school/git/advanced-practice.git
$ git fetch upstream
```
Check the remotes
```bash
$ git remote -v
```
# Getting Started (2)
Create your own branch `myBranch` based on the `develop` branch from `usptream` using the `-b` flag
```bash
$ git checkout -b myBranch upstream/develop
```
* Please generate your SSH before with `$ ssh-keygen -t rsa` and set it in Gitlab!
* Add a remote `upstream`
```bash
$ cd advanced-practice
# add upstream URL
$ git remote add upstream ssh://git@git-r3lab-server.uni.lu:8022/R3/school/git/advanced-practice.git
$ git fetch upstream
```
* Check the remotes with:
```bash
$ git remote -v
```
* Create the `develop` branch and your own branch `myBranch` based on the `develop` branch from `upstream` using the `-b` flag
```bash
$ git checkout -b develop upstream/develop
$ git checkout -b myBranch
```
......
......@@ -69,6 +69,8 @@ $ git log
# Interactive Rebasing - flag `-i`
* An interactive rebase is performed with the `-i` flag:
```bash
git rebase -i <branch>
```
......@@ -98,7 +100,7 @@ $ echo "# William Odell" > william.md
$ # add and commit the file william.md with the message 'add william to attendee list'
$ echo "# Roberta Ross" > roberta.md
$ # add and commit the file roberta.md with the message 'add roberta to attendee list'
$ git push origin yourBranch
$ git push origin myBranch
```
Now, we want to:
......@@ -131,7 +133,8 @@ $ pick abcdef0 add roberta to attendee list
$ reword 1234567 add william to attendee list
$ fixup abcdef0 add roberta to attendee list
```
* Change the message of commit `1234567` to `Add William and Roberta to the attendee list`.
* Edit by typing `i`
* Change the message of commit `1234567` to `Add William and Roberta to the attendee list`
* Save with `:wq`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment