Skip to content
Snippets Groups Projects
Unverified Commit 9992a5bb authored by Laurent Modolo's avatar Laurent Modolo
Browse files

fix first part of the TP

parent cf9febaa
Branches
No related tags found
No related merge requests found
...@@ -146,7 +146,7 @@ git status ...@@ -146,7 +146,7 @@ git status
git st git st
``` ```
We defined `st` as an alias of `status` in the `~/.gitconfig` file, so the two command are equivalent. We defined `st` as an alias of `status` in the `~/.gitconfig` file, so the two commands are equivalent.
Our first code: Our first code:
...@@ -182,30 +182,27 @@ The current state of `data/letter.txt` is recorded. ...@@ -182,30 +182,27 @@ The current state of `data/letter.txt` is recorded.
![git add made a copy of the a file creating the corresponding blob](img/staging_1.png){height=150px} ![git add made a copy of the a file creating the corresponding blob](img/staging_1.png){height=150px}
```sh ```sh
echo 'b' > data/letter.txt git ls-files --stage
ls -R .git/objects/ echo "1234" > data/number.txt
git st git add data/number.txt
git ls-files --stage
printf "1" > data/number.txt
``` ```
We changed the state of `data/letter.txt`, but those changes are not staged for commit. We changed the state of `data/number.txt`, but those changes are not staged for commit.
The previous states of `data/letter.txt` is still recorded *somewhere* even if it differs from its current state. The previous states of `data/number.txt` is still recorded *somewhere* even if it differs from its current state.
This *somewhere* is called the staging area (where you stage changes). This *somewhere* is called the staging area (where you stage changes).
![modifications in the working area don't affect what's stored in Git](img/staging_2.png){height=150px}
```sh ```sh
git ls-files --stage
printf '1234' > data/number.txt
git add data/number.txt
git ls-files --stage
printf '1' > data/number.txt
git add data/number.txt git add data/number.txt
git ls-files --stage git ls-files --stage
``` ```
![The staging area is different from the working directory](img/staging_3.png){height=150px} ![modifications in the working area don't affect what's stored in Git](img/staging_2.png){height=150px}
![The staging area is different from the working directory](img/staging_3.png)
You can save the state of the staging area definitively with the command `git commit` You can save the state of the staging area definitively with the command `git commit`
...@@ -216,7 +213,7 @@ git st ...@@ -216,7 +213,7 @@ git st
Here "a1" is the message associated with the commit. Here "a1" is the message associated with the commit.
![Write clear and informative commit messages ([xkcd](https://xkcd.com/))](img/git_commit_xkcd.png){height=250px} ![Write clear and informative commit messages ([xkcd](https://xkcd.com/))](img/git_commit_xkcd.png)
> There are two rules for committing: > There are two rules for committing:
> >
...@@ -232,7 +229,7 @@ git lo ...@@ -232,7 +229,7 @@ git lo
``` ```
You wrote your first commit with an unique identifier: You wrote your first commit with an unique identifier:
`8afd9d3fef28f7a9d582c9fa11d3702a9161feb4` `531019e7119268c4dae5ac44ef5929165794f4b0`
> `git commit`: > `git commit`:
> - creates a tree graph to represent the content of the version of the project being committed > - creates a tree graph to represent the content of the version of the project being committed
...@@ -240,13 +237,13 @@ You wrote your first commit with an unique identifier: ...@@ -240,13 +237,13 @@ You wrote your first commit with an unique identifier:
> - points the current branch to the new commit object > - points the current branch to the new commit object
```sh ```sh
git ls-tree -r 8afd9d3fef28f7a9d582c9fa11d3702a9161feb4 git ls-tree -r 531019e7119268c4dae5ac44ef5929165794f4b0
git ls-tree -d 8afd9d3fef28f7a9d582c9fa11d3702a9161feb4 git ls-tree -d 531019e7119268c4dae5ac44ef5929165794f4b0
``` ```
The `8afd9d3fef28f7a9d582c9fa11d3702a9161feb4` point to the tree object with point to the two committed files. The `531019e7119268c4dae5ac44ef5929165794f4b0` point to the tree object with point to the two committed files.
[The commit a1 record the tree structure and the files corresponding to the staging area](img/commit_a1.png){height=150px} [The commit a1 record the tree structure and the files corresponding to the staging area](img/commit_a1.png)
In git, there are 3 areas: In git, there are 3 areas:
...@@ -254,7 +251,7 @@ In git, there are 3 areas: ...@@ -254,7 +251,7 @@ In git, there are 3 areas:
- The staging area (in the `.git` folder) - The staging area (in the `.git` folder)
- The repository (also in the `.git` folder) - The repository (also in the `.git` folder)
![git areas](img/three_git_areas.png){height=250px} ![git areas](img/three_git_areas.png)
The repository is a chain of commit beginning with your first commit. The repository is a chain of commit beginning with your first commit.
...@@ -277,7 +274,7 @@ You can navigate to a given point of the repository with the command `git checko ...@@ -277,7 +274,7 @@ You can navigate to a given point of the repository with the command `git checko
```sh ```sh
git log git log
cat data/number.txt cat data/number.txt
git checkout 8afd9d3 git checkout 531019e
cat data/number.txt cat data/number.txt
``` ```
...@@ -336,7 +333,7 @@ git lo ...@@ -336,7 +333,7 @@ git lo
We are back at the leaf of the git repository. We are back at the leaf of the git repository.
### Growing the repository tree ## Growing the repository tree
We only have one branch, the `master` branch in our repository. We only have one branch, the `master` branch in our repository.
This mean that we only have one timeline in our history. This mean that we only have one timeline in our history.
...@@ -350,9 +347,9 @@ git lo ...@@ -350,9 +347,9 @@ git lo
``` ```
```sh ```sh
echo '1' > data/number.txt echo '3' > data/number.txt
git add data/number.txt git add data/number.txt
git commit -m "1: first commit in dev" git commit -m "a3"
git lo git lo
``` ```
...@@ -360,17 +357,18 @@ If we have two branches `dev` and `master`, it's hard to tell them apart (`maste ...@@ -360,17 +357,18 @@ If we have two branches `dev` and `master`, it's hard to tell them apart (`maste
```sh ```sh
git co master git co master
echo 'c' > data/letter.txt echo 'b' > data/letter.txt
git add data/letter.txt git add data/letter.txt
git commit -m "c: third commit in master" git commit -m "b2"
git lo git lo
``` ```
Congratulation you have a fork in your git repository ! Congratulation you have a fork in your git repository !
Lets make another one called `dict` from the branch `master` where `data/letter.txt` contain the letter `d`. Lets make another one called `dev2` from the branch `master` where `data/letter.txt` contain the letter `c`.
Then create the corresponding commit `c2`
### Merging branches ## Merging branches
When you are ready to incorporate your new code in your main branch you need to merge the branch containing the new code into your main branch. When you are ready to incorporate your new code in your main branch you need to merge the branch containing the new code into your main branch.
You can merge branch with the command `git merge`. You can merge branch with the command `git merge`.
...@@ -383,12 +381,12 @@ git branch ...@@ -383,12 +381,12 @@ git branch
git merge master git merge master
``` ```
Can we merge `master` into `dict` ? Can we merge `master` into `dev2` ?
```sh ```sh
git co master git co master
git branch git branch
git merge dict git merge dev2
``` ```
There are three types of merge : There are three types of merge :
...@@ -419,13 +417,15 @@ git lo ...@@ -419,13 +417,15 @@ git lo
``` ```
The new commit is a `Merge` commit with the identifiers of its two ancestors. The new commit is a `Merge` commit with the identifiers of its two ancestors.
Here, we didn't have any conflict: in the `dev` branch, we worked on the `data/numberber.txt` file while in the `master` branch, we worked on the `data/letter.txt` file. Here, we didn't have any conflict: in the `dev` branch, we worked on the `data/number.txt` file while in the `master` branch, we worked on the `data/letter.txt` file.
Let's complicate things ! Let's complicate things !
Create a new commit in the `master` branch where the content of `data/letter.txt` is set to `e`.
Create a new commit `e3` in the `master` branch where the content of `data/letter.txt` is set to `e`.
Then create a new commit in the `dev` branch where the content of `data/letter.txt` is set to `f` and go back the the branch `master`. Then create a new commit in the `dev` branch where the content of `data/letter.txt` is set to `f` and go back the the branch `master`.
```sh ```sh
git lt
git branch git branch
git merge dev git merge dev
git st git st
...@@ -449,11 +449,12 @@ git add data/letter.txt ...@@ -449,11 +449,12 @@ git add data/letter.txt
git st git st
git commit git commit
git st git st
git lt
``` ```
You now, know how to deal with the different kind of merge You now, know how to deal with the different kind of merge
## Part 2: Git togetherdata # Part 2: Git together
We start by cloning an existing repository. We start by cloning an existing repository.
`file_handle.py` is a small python script to handle the dating and the access to dated files in a format compatible with the [guide of good practices at the LBMC](http://www.ens-lyon.fr/LBMC/intranet/fichiers/bioinfo/good-practices.pdf). `file_handle.py` is a small python script to handle the dating and the access to dated files in a format compatible with the [guide of good practices at the LBMC](http://www.ens-lyon.fr/LBMC/intranet/fichiers/bioinfo/good-practices.pdf).
...@@ -644,9 +645,6 @@ git push perso ...@@ -644,9 +645,6 @@ git push perso
You can see the graph of our modifications at the following address [http://gitlab.biologie.ens-lyon.fr/user_name/git_basis/network/master](http://gitlab.biologie.ens-lyon.fr/user_name/git_basis/network/master) You can see the graph of our modifications at the following address [http://gitlab.biologie.ens-lyon.fr/user_name/git_basis/network/master](http://gitlab.biologie.ens-lyon.fr/user_name/git_basis/network/master)
# Part 2: Git Together
Branch management is at the heart of Git. These powerful mechanisms will help Branch management is at the heart of Git. These powerful mechanisms will help
you to work in collaboration with others. For the second part of the TP you you to work in collaboration with others. For the second part of the TP you
need to pair with someone else. We will refer to you as developer **W** need to pair with someone else. We will refer to you as developer **W**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment