3rd of March, 2022
Git is a distributed version control system.
git clone https://gitlab.epfl.ch/afontain/test-project.git
git add hello-world.py
$ git status On branch main No commits yet Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: hello-world.py
git commit -m "My commit message"
(if you don't use
-m, you will be put in a text editor to write the message)
A commit is when you “save” a version of your files
A commit is the unit of change. It roughly contains:
The value of all these fields will give to your commit its hash, which is used to identify the commit.
$ git show commit 6a195fc8a9ce6059e5db4b51303bde0334473687 (HEAD -> main) Author: Antoine Fontaine <email@example.com> Date: Sun Feb 20 18:03:47 2022 +0100 Add hello-world.py diff --git a/hello-world.py b/hello-world.py new file mode 100644 index 0000000..e94acca --- /dev/null +++ b/hello-world.py @@ -0,0 +1 @@ +print("hello, world!")
(here we'll add a line to our file)
$ git diff diff --git a/hello-world.py b/hello-world.py index e94acca..0672c0c 100644 --- a/hello-world.py +++ b/hello-world.py @@ -1 +1,2 @@ print("hello, world!") +print("this is a simple python program")
If you modify a file tracked by git, you can commit it by specifying with the command line
git commit hello-world.py -m "My other message"
Remember the git logo? that's a tree with branches.
git switch dev
or, if it doesn't exist already
git switch --create mybranch
$ git branch * dev main
git merge some-feature
You typically switch to master before doing this
(This will be covered in detail in the next talk)
2022-03-02 11:52 +0100 Antoine Fontaine M─┐ [main] Merge branch 'some-feature' 2022-03-02 11:50 +0100 Antoine Fontaine │ o [some-feature] checking the comput 2022-03-02 11:51 +0100 Antoine Fontaine o │ some changes on main 2022-03-02 10:53 +0100 Antoine Fontaine o─┘ [dev] My other message 2022-03-02 10:48 +0100 Antoine Fontaine I Initial commit
Here we'll introduce GitLab as the hosting platform
Here, I won't post steps, raise your hand and ask for help, or look it up on the internet
You only have to do this once
You typically use
git switch main before running it
To learn more about Git come to the talk on
Thursday 7th of April