add basic git commands authored by Boman Romain's avatar Boman Romain
......@@ -133,5 +133,68 @@ If you prefer youtube videos, here are some links about git and GitLab:
* [Git for GitLab (Beginner's FULL COURSE)](https://www.youtube.com/watch?v=4lxvVj7wlZw&ab_channel=ValentinDespa)
* [Learn GitLab in 3 Hours | GitLab Complete Tutorial For Beginners](https://www.youtube.com/watch?v=8aV5AxJrHDg&ab_channel=LambdaTest)
# Basic git workflow
Create a repository:
* Do this on GitLab, 1 project per group,
* set your project as "Public"
* invite your co-workers as members of the project (developers).
Clone the repository:
```
git clone [copy/paste the URL here starting with git@]
```
Get the current state of the working copy (each time you have a doubt!):
```
git status
```
Create a branch named `mybranch`:
```
git checkout -b mybranch
```
Switch to the existing branch `mybranch`:
```
git checkout mybranch
```
See the modifications of your working copy:
```
git diff
```
Create a local commit on your laptop:
```
git add [files] # or "git add ." to add everything (BUT be careful!)
git status # always check what will be commited!
git commit -m "type a meaningful description"
```
Send the commit(s) of the current branch to GitLab:
```
git push
```
Get someone else's commits from GitLab (do not merge anything):
```
git fetch
```
Merge `otherbranch` to `mybranch`:
```
git checkout mybranch # be sure to be on your branch!
git fetch # retrieve the last state of all branches
git merge origin/otherbranch # do the merge
# [ resolve conficts with an editor]
git add [files where conflicts occured]
git push
```
See the "tree of commits" on your Windows PC:
```
gitk --all
```
Create a "merge request" (instead of pushing to `master`):
* Do this on GitLab.
Tag your project for a deadline:
* Do this on GitLab.
# Hints
* Do not push unnecessary files! (add a `.gitignore` to your project),
* Talk with the other developers.
* Most of the previous commands are integrated into VS Code. You can easily see the modified files, prepare a commit or resolve conflicts (with your mouse).