Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
R3
school
courses
Commits
bdc49fa5
Verified
Commit
bdc49fa5
authored
Mar 30, 2020
by
Laurent Heirendt
✈
Browse files
copy of git course from previous
parent
a2634d99
Changes
90
Hide whitespace changes
Inline
Side-by-side
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/best_practices.md
0 → 100644
View file @
bdc49fa5
# Best practices
*
`pull`
before
`push`
*
Work on your
<font
color=
"red"
>
own
</font>
branch (in your own fork), and
**not**
on
`master`
and
**not**
on
`develop`
*
Do
**not push**
to
`master`
, but
**submit a PR**
*
Get your code
**reviewed**
by your peers (submit a PR!)
*
Submit a PR
**often**
!
*
`clone`
a repository, do not download the
`.zip`
file.
*
Do
**not**
combine
`git`
commands
```
bash
$
git commit
-am
"myMessage"
# do not do this
```
*
Stage only 1 file at once using
```
bash
$
git add myFile.md
```
*
Commit
**only a few files**
at once (after multiple separate
`git add`
commands)
*
`Push`
often - avoid conflicts
Remember:
**A `push` a day keeps conflicts away!**
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/branches.md
0 → 100644
View file @
bdc49fa5
# Development scheme
Generally, in a repository, there are guidelines for contributing.
<div
class=
"fragment"
>
A common development scheme is dual with a:
-
**development**
version of the code on
`develop`
-
**stable**
version of the code on
`master`
A
**version**
of the code is referred to as a
**branch**
.
<div
class=
"fragment"
>
<img
src=
"slides/img/icon-live-demo.png"
height=
"100px"
>
<font
color=
"red"
>
In the practice repository, the development branch is called
`develop`
!
</font>
<div
class=
"fragment"
>

Use this dual development scheme for your own repositories!
# Branches
A
**version**
of the code (i.e., a
**branch**
) is made up of a sequence of code changes.
<div
class=
"fragment"
>
These individual code changes are called
**commits**
.
For instance, the
`master`
and
`develop`
branches can be represented as a timeline:
<img
src=
"slides/img/branch-master.png"
class=
"branch-master"
height=
"500em"
/>
# Switch between branches
List all branches of the repository with
```
bash
$
git branch
-a
```
Exit by typing
`q`
. The branch with the
*
is the current branch.
<div
class=
"fragment"
>
Checkout another branch
```
bash
$
git checkout <branchName>
```
<div
class=
"fragment"
>
You can switch to the
`develop`
branch with
```
bash
$
git checkout develop
```
If the local branch does not exist but the remote does, it is created automatically.
<div
class=
"fragment"
>
<img
src=
"slides/img/icon-live-demo.png"
height=
"100px"
>
# Create your own version
Assume that you want to work on a file:
<div
class=
"fragment"
>
<font
color=
"red"
>
Create a new
**branch**
!
</font>
```
bash
$
git checkout
-b
myBranch
```
The
`-b`
flag creates the branch. Locally, you have your own version now:
<img
src=
"slides/img/branch-create.png"
class=
"branch-create"
height=
"500em"
/>
Push your version to your fork:
```
bash
$
git push origin myBranch
```
<div
class=
"fragment"
>
<img
src=
"slides/img/icon-live-demo.png"
height=
"100px"
>
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/cloneRepo.md
0 → 100644
View file @
bdc49fa5
# How do I start working on a repository?
You have to
`clone`
it first:
```
bash
$
git clone git@github.com:userName/myRepo.git myRepo
```
If you did not configure your SSH key, clone using HTTPS:
```
bash
$
git clone https://github.com/userName/myRepo.git myRepo
```
You will be prompted to enter your credentials.
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/configuration.md
0 → 100644
View file @
bdc49fa5
# How to configure `git`?
```
bash
$
git config
--global
user.name
"Firstname Lastname"
$
git config
--global
user.email
"first.last@uni.lu"
```
Test whether your username and email have been registered
```
bash
$
git config
--list
```
This should list the configuration with
`user.name`
and
`user.email`
.
Exit by typing
`q`
.
# What is an SSH key?
An SSH key is a secure access credential.
**Principle**
:
<br><br>
Communicate
**securely**
with Github/Gitlab
**without**
entering the username/password.
# How do I get and set my SSH key?
Check if you already have an SSH key:
```
bash
$
ls
-al
~/.ssh
```
If there are 2 files named
`id_rsa`
, you have an SSH key.
If you don’t have yet an SSH key, you have to generate one:
```
bash
$
ssh-keygen
-t
rsa
# -b 4096
```
Then, add the SSH key to Github/Gitlab.
<img
src=
"slides/img/icon-live-demo.png"
height=
"100px"
>
\ No newline at end of file
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/essential_commands.md
0 → 100644
View file @
bdc49fa5
# The 5 essential commands
**Yes**
, you only need 5 commands!
`pull, status, add, commit, push`
or in other words (remember these!):
```
bash
$
git pull <remote> <branch>
$
git status
$
git add myFile.md
# example
$
git commit
-m
"myMessage"
# example
$
git push <remote> <branch>
```
# Pull the latest version of an existing branch
Pull the latest revision on branch
`myBranch`
:
```
bash
$
git pull origin myBranch
# Already up to date
```
<div
class=
"fragment"
>
Verify its
`status`
with:
```
bash
$
git status
```
# Modify a file
Copy the file
`template.md`
in the folder
`_attendees`
and rename it with your firstname:
```
bash
$
cd
_attendees
$
cp
template.md myName.md
```
Then, make your changes with your favorite editor!
# Add your file to the stage
First, check the repository status
```
bash
$
git status
# uncommitted changes (displayed in red)
```
<div
class=
"fragment"
>
Now, add the file (bring it on stage)
```
bash
$
git add myName.md
# replace myName
$
git status
# returns the same as before, generally in green (means staged)
```
<div
class=
"fragment"
>
**ADVANCED**
: If there have been more changes after the file has been added, you can see your changes in the terminal
```
bash
$
git diff
```
exit with
`q`
# Add a commit message
```
bash
$
git commit
-m
"Add the profile of <myName>"
$
git status
```
# Push your file to your fork
```
bash
$
git push origin myBranch
```
<div
class=
"fragment"
>
**ADVANCED**
: see the log of all the commits (and your last one) in the terminal
```
bash
$
git log
```
exit by typing
`q`
.
\ No newline at end of file
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/forks.md
0 → 100644
View file @
bdc49fa5
# What is a `fork`?
<img
src=
"slides/img/fork.jpg"
class=
"as-is"
height=
"500em"
/>
<!--http://www.cndajin.com/data/wls/246/22302193.jpg-->
# Not really ...
<img
src=
"slides/img/fork-crossed.png"
class=
"as-is"
height=
"500em"
/>
# What is a `fork`?
In general, when contributing to a repository, you only have
**read**
access.
In other words, you can only
**pull**
(unless it is your own repository or access has been granted).
In general, you
**cannot write**
changes. In other words, you do not have
**push**
access.
You have to work on your
**own copy**
.
In other words, you have to work on your own
<font
color=
"red"
>
**fork**
</font>
.
# How to get a fork?
Browse to the original repository and click on the button
`Fork`
:

<img
src=
"slides/img/icon-live-demo.png"
height=
"100px"
>
# Time to practice!
Fork the practice repository:
<br><br>
https://github.com/LCSB-BioCore/basic-git-practice
Then, clone your fork to your home directory!
<img
src=
"slides/img/icon-live-demo.png"
height=
"100px"
>
```
bash
$
git clone git@github.com:<yourName>/basic-git-practice.git
```
Change to the practice directory with:
```
bash
$
cd
basic-git-practice
```
# A note on shortcuts ...
<font
color=
"red"
>
Any other rudimentary method such as
*'I simply download the `.zip` and unzip it - works like a charm!'*
shall
**be avoided**
!
</font>
**Why?**
# How to update my fork?
As you have your own fork, it will not automatically be updated once the original repository is updated.

You have to update it yourself!
**More on that later!**
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/github_gitlab.md
0 → 100644
View file @
bdc49fa5
# GitHub and GitLab
<img
src=
"https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
alt=
"GitHub"
style=
"width: 200px;"
/>
<img
src=
"https://gitlab.com/gitlab-com/gitlab-artwork/raw/master/logo/logo-extra-whitespace.png"
alt=
"GitLab"
style=
"width: 200px;"
/>
GitHub and GitLab are VCS systems.
GitHub/Gitlab are both
**publicly available**
, but GitLab can be
**on-premise**
.
Positive point: GitHub and GitLab are (almost) the same.
<img
src=
"slides/img/icon-live-demo.png"
height=
"100px"
>
-
**GitHub**
:
[
https://github.com
](
https://github.com
)
-
Public GitLab:
[
https://gitlab.com
](
https://gitlab.com
)
-
LCSB specific:
[
https://git-r3lab.uni.lu
](
https://git-r3lab.uni.lu
)
\ No newline at end of file
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/img/Git-Logo-Black.png
0 → 100644
View file @
bdc49fa5
5.55 KB
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/img/arianeLaunch.mov
0 → 100644
LFS
View file @
bdc49fa5
File added
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/img/branch-create.png
0 → 100644
View file @
bdc49fa5
99.1 KB
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/img/branch-master.png
0 → 100644
View file @
bdc49fa5
84.7 KB
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/img/branch-merge.png
0 → 100644
View file @
bdc49fa5
106 KB
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/img/bulb.png
0 → 100644
View file @
bdc49fa5
4.72 KB
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/img/computerCode.png
0 → 100644
View file @
bdc49fa5
166 KB
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/img/favicon.ico
0 → 100644
View file @
bdc49fa5
39.9 KB
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/img/fork-crossed.png
0 → 100644
View file @
bdc49fa5
1.71 MB
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/img/fork.jpg
0 → 100644
View file @
bdc49fa5
35.2 KB
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/img/git_definition.png
0 → 100644
View file @
bdc49fa5
31 KB
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/img/github_app.png
0 → 100644
View file @
bdc49fa5
266 KB
2020/2020-03-30_basicGitTraining/2019-06-11_basicGitTraining/slides/img/icon-live-demo.png
0 → 100644
View file @
bdc49fa5
43.4 KB
Prev
1
2
3
4
5
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment