| ... | @@ -137,7 +137,7 @@ If you prefer youtube videos, here are some links about git and GitLab: |
... | @@ -137,7 +137,7 @@ If you prefer youtube videos, here are some links about git and GitLab: |
|
|
|
|
|
|
|
Create a repository:
|
|
Create a repository:
|
|
|
* Do this on GitLab, 1 project per group,
|
|
* Do this on GitLab, 1 project per group,
|
|
|
* set your project as "Public"
|
|
* set your project as "Public",
|
|
|
* invite your co-workers as members of the project (developers).
|
|
* invite your co-workers as members of the project (developers).
|
|
|
Clone the repository:
|
|
Clone the repository:
|
|
|
```
|
|
```
|
| ... | @@ -151,11 +151,11 @@ Create a branch named `mybranch`: |
... | @@ -151,11 +151,11 @@ Create a branch named `mybranch`: |
|
|
```
|
|
```
|
|
|
git checkout -b mybranch
|
|
git checkout -b mybranch
|
|
|
```
|
|
```
|
|
|
Switch to the existing branch `mybranch`:
|
|
Switch to the *existing* branch `otherbranch`:
|
|
|
```
|
|
```
|
|
|
git checkout mybranch
|
|
git checkout otherbranch
|
|
|
```
|
|
```
|
|
|
See the modifications of your working copy:
|
|
See the modifications of your *working copy* (the files on your laptop):
|
|
|
```
|
|
```
|
|
|
git diff
|
|
git diff
|
|
|
```
|
|
```
|
| ... | @@ -165,11 +165,21 @@ git add [files] # or "git add ." to add everything (BUT be careful!) |
... | @@ -165,11 +165,21 @@ git add [files] # or "git add ." to add everything (BUT be careful!) |
|
|
git status # always check what will be commited!
|
|
git status # always check what will be commited!
|
|
|
git commit -m "type a meaningful description"
|
|
git commit -m "type a meaningful description"
|
|
|
```
|
|
```
|
|
|
Send the commit(s) of the current branch to GitLab:
|
|
Remove a file:
|
|
|
|
```
|
|
|
|
[remove the file from your hard drive]
|
|
|
|
git add [file] # you must "add" the deletion!
|
|
|
|
git commit -m "[file] removed"
|
|
|
|
```
|
|
|
|
Send the commit(s) of the current branch to GitLab (the branch *does not exist* on GitLab):
|
|
|
|
```
|
|
|
|
git push -u origin mybranch
|
|
|
|
```
|
|
|
|
Send the commit(s) of the current branch to GitLab (the branch *does already exist* on GitLab):
|
|
|
```
|
|
```
|
|
|
git push
|
|
git push
|
|
|
```
|
|
```
|
|
|
Get someone else's commits from GitLab (do not merge anything):
|
|
Copy the state of GitLab to your `.git` folder (this does not modify your files - do this as soon as you know that new commits have been sent to GitLab by the other developers):
|
|
|
```
|
|
```
|
|
|
git fetch
|
|
git fetch
|
|
|
```
|
|
```
|
| ... | @@ -182,19 +192,29 @@ git merge origin/otherbranch # do the merge |
... | @@ -182,19 +192,29 @@ git merge origin/otherbranch # do the merge |
|
|
git add [files where conflicts occured]
|
|
git add [files where conflicts occured]
|
|
|
git push
|
|
git push
|
|
|
```
|
|
```
|
|
|
See the "tree of commits" on your Windows PC:
|
|
Retrieve the commits of the current branch that are on GitLab but are not on my PC (this is useful if you switch to someone else's branch or if you work from 2 different places such as your laptop and the CECI clusters):
|
|
|
|
```
|
|
|
|
git pull
|
|
|
|
```
|
|
|
|
See the "tree of commits" graphically on your Windows PC:
|
|
|
```
|
|
```
|
|
|
gitk --all
|
|
gitk --all
|
|
|
```
|
|
```
|
|
|
Create a "merge request" (instead of pushing to `master`):
|
|
Create a "merge request" (instead of pushing to `master`):
|
|
|
* Do this on GitLab.
|
|
* Do this on GitLab.
|
|
|
|
* First, merge master into your branch.
|
|
|
|
* Check that your code works and you haven't broken something (run some tests)
|
|
|
|
* Write some text explaining what you have done in your branch.
|
|
|
|
* The other developers will receive an e-mail telling them that you want to update master.
|
|
|
|
* Wait for their comments and agreement before merging the merge request.
|
|
|
|
|
|
|
|
Tag your project for a deadline:
|
|
Tag your project for a deadline (a "tag" is a string which identifies a particular commit of your project):
|
|
|
* Do this on GitLab.
|
|
* Do this on GitLab.
|
|
|
|
|
|
|
|
# Hints
|
|
# Hints
|
|
|
|
|
|
|
|
* Do not push unnecessary files! (add a `.gitignore` to your project),
|
|
* Do not push unnecessary files! Add a `.gitignore` to your project. Always check that you do not send the numerical results of your code or the program binaries to GitLab. This is very important because it is not easy to remove files from the history stored on GitLab.
|
|
|
* Talk with the other developers.
|
|
* Keep the "master" branch stable (it should always produce no errors during the build and all the tests should run successfully!).
|
|
|
* 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).
|
|
* Tell what you are currently doing to the other developers (using comments, issues, merge requests on GitLab... or by any other mean).
|
|
|
|
* Most of the previous commands are integrated into VS Code. You can easily see the modified files, prepare a commit or resolve conflicts (through the GUI, with your mouse!).
|
|
|
|
|
|