Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a3c8b4ef authored by MALANDAIN Mathias's avatar MALANDAIN Mathias
Browse files

Replace links in sections 3 and 4 + fix a picture

parent acff0560
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@ The first thing I have to do, before working on the code, is to **clone** the re
Of course, just typing `git clone` in your terminal will give you an error: "What am I supposed to clone?" To answer that question, go back to the page of the project on GitLab, and notice the unmissable "Clone" button. Click on it.
![](https://notes.inria.fr/uploads/upload_47e5fa95031dfe8ff4ec8a925c2f3fd1.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/A-cloning/project-clone.jpg){: .mx-auto.d-block :}
We went through the (reasonable) hassle of configuring SSH authentication for GitLab, why wouldn't we reap the benefits? The contents of the text box below "Clone with SSH" (it will always start with `git@`) is our missing argument for `git clone`. Open a terminal, `cd` into the folder you want to clone into, and put the pieces together; in this case, the full command would be
......@@ -38,7 +38,7 @@ git clone git@gitlab.inria.fr:bakery/bread/multigrain-baguette.git
Type your SSH key passphrase when asked, then wait for the cloning operation to end. A new folder called `multigrain-baguette` just appeared. This is what it looks on my computer:
![](https://notes.inria.fr/uploads/upload_ab63921c0aeed85d3242ba1f5e9ed1a5.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/A-cloning/local-1.jpg){: .mx-auto.d-block :}
The `.git` folder is hidden by default (if you do not see it in your working copy, do not worry, you still have it). This is where the magic actually happens, but we are not delving into this before getting the grip of how to use Git. For the moment, just remember that **there is no reason in the world for you to edit anything in the `.git` folder**. For all intents and purposes, the whole project is a `README.md` file and nothing more.
......@@ -68,7 +68,7 @@ To put it in good use, I will be working on two separate things in my project: e
After my work session, I will ask for information about the **status** of the project. Guess the command? That's `git status` indeed. If I run it from the root directory of my working copy, this is what I get:
![](https://notes.inria.fr/uploads/upload_9f329afdf47dbbaf04c80560eacf7c46.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/A-cloning/local-2.jpg){: .mx-auto.d-block :}
* For now, there is only one branch, called `main`: it is the one created by default (it used to be called `master`, and a lot of online tutorials were not updated, so be cautious). We shall see later how to deal with more than one branch.
* Also, my local branch seems to be up to date with the `main` branch on `origin`, that is, the version of the server. I have no commit that the server is unaware of, and no commit was pushed to the repo while I was looking away... presumably (we will get back to this).
......@@ -77,7 +77,7 @@ After my work session, I will ask for information about the **status** of the pr
The changes I made were very different and independent: it makes sense to put them in two separate commits. Let us start with the `README`: I can just type `git add README.md`, which means *"stage all changes I made in `README.md`"*. Now, a new `git status` gives me this:
![](https://notes.inria.fr/uploads/upload_f22fd14136dc967312fe47204e4409d2.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/A-cloning/local-3.jpg){: .mx-auto.d-block :}
My first actual commit will not contain anything more, so that I can just run something like
......@@ -87,7 +87,7 @@ git commit -m "Add relevant info to the README file"
Did I do everything right so far? My new best friend `git status` will tell me:
![](https://notes.inria.fr/uploads/upload_b79cc925730fb4395fd6f87e5c483974.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/A-cloning/local-4.jpg){: .mx-auto.d-block :}
Alright, I have one commit ready to be pushed, a file that is still untracked (it does not exist at all on the repo, only in my working copy), and my staging area is empty again. I can now add my new file and put that one in a new commit:
......@@ -102,15 +102,15 @@ The result of `git status` are now pretty obvious: no more changes to commit, em
Going back to the project's page on GitLab, I can see that some changes occurred recently:
![](https://notes.inria.fr/uploads/upload_c29174c01f9f816e1d421ff049170cc7.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/A-cloning/local-5.jpg){: .mx-auto.d-block :}
The "Last commit" field displays the message associated with the last commit that actually changed the file, and the "Last update" field tells you when *that* commit was created. I can also check the graph of my repo:
![](https://notes.inria.fr/uploads/upload_8e05408c4fd6d0a28f96b912ed11fac6.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/A-cloning/gitlab-graph-1.jpg){: .mx-auto.d-block :}
For the moment, the graph of this project is very straightforward, as expected.
![](https://notes.inria.fr/uploads/upload_a1d67d583c99749e6238589078360366.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/A-cloning/gitlab-graph-2.jpg){: .mx-auto.d-block :}
Time to wrap up this part!
......@@ -165,21 +165,21 @@ If you want Git to be aware of changes that were made on the origin, you will ha
In order to illustrate this, I asked my doppelganger to change a few things in my recipe, from the online IDE on GitLab. A new commit was created and pushed. I will now run `git status` from my computer:
![](https://notes.inria.fr/uploads/upload_7dd1ff6fa9f68f83c8a17d81d67e493f.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/B-fetching-pulling/git-fetch-1.jpg){: .mx-auto.d-block :}
"What do you mean, up to date?", you think. "I happen to know this is not real. Stop lying to me."
Well, as I already said, `git status` is not lying to you: he just chose the wrong words. You see, your branch is in sync with *the last version of origin/main it knows*. However, if you want Git to update its knowledge, you have to run `git fetch` (and, of course, you will be asked your passphrase):
![](https://notes.inria.fr/uploads/upload_202ce494e142b24328d4e151c4b5b90d.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/B-fetching-pulling/git-fetch-2.jpg){: .mx-auto.d-block :}
Something happened, right? Let's now run `git status` again:
![](https://notes.inria.fr/uploads/upload_e86035d5a59497accd7b59ccb977a413.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/B-fetching-pulling/git-fetch-3.jpg){: .mx-auto.d-block :}
See, `git status` was not lying! Now that it got the latest news about the origin, you are told that you are one commit behind, and that you can "fast-forward", whatever that means! We indeed have to talk about a few other things before coming back to fast-forwarding. The only thing you have to know is that the situation is still pretty simple to handle: you did not change anything to your working copy, you just happen to be one commit behind. Git suggests that you update your working copy with `git pull`: why not?
![](https://notes.inria.fr/uploads/upload_9607283bc4b34150e16a60f8209a6338.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/B-fetching-pulling/git-fetch-4.jpg){: .mx-auto.d-block :}
Great! Now, my dopperganger's changes appear in my working copy. A few things do not seem to make sense, though. First, why did I have to type my passphrase once again? Second, what the heck does "rewinding head" mean? Third, what is "f5269..."?
......@@ -245,15 +245,15 @@ However, there is one line that we both edited in different ways, and as he push
I actually forgot to pull before pushing. This makes the situation even worse, right? Will my `git push` create a black hole? Nope:
![](https://notes.inria.fr/uploads/upload_9de9418855434cd230a6a5e04dfa4ea6.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/C-conflict/conflict-1.jpg){: .mx-auto.d-block :}
Git checked, and I happen to be late to the party. It tells me that I should pull before pushing again. Thank you, Git. Let me run `git pull`, then.
![](https://notes.inria.fr/uploads/upload_45c2280cc29c9a9f1ae42efdff0b83d2.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/C-conflict/conflict-2.jpg){: .mx-auto.d-block :}
The first time I saw something like this, this was my reaction:
![](https://notes.inria.fr/uploads/upload_c09a0e7f645a28b6b9f18393a1ac9923.jpg){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/C-conflict/panic.jpg){: .mx-auto.d-block :}
It's actually not that bad. The only file with a conflict is `recipe-v1.txt`, and the rest of the text tells me what I have to do to fix the problem.
......@@ -262,7 +262,7 @@ It's actually not that bad. The only file with a conflict is `recipe-v1.txt`, an
Opening the conflicting file, I notice something unusual:
![](https://notes.inria.fr/uploads/upload_0ce77450564c1d43588898c1aa266414.png){: .mx-auto.d-block :}
![](/assets/img/03-linear-git-project/C-conflict/conflict-3.jpg){: .mx-auto.d-block :}
This, right there, is Git showing me where the differences are. The block with `HEAD` is the incoming change, the one that was made by people who pushed before I pulled. The block below contains my changes, and it even gives me the name of the commit in which I made this change. Now I can just pick and choose, or maybe create a third version: as long as I remove the conflict markers `<<<<<<<`, `=======` and `>>>>>>>`, Git will trust that I solved the conflict.
......
This diff is collapsed.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment