|
|
## Welcome to GitLab!
|
|
|
|
|
|
> If this is your first time using `git` or simply using this GitLab server, please read through __[First time using GitLab](#first-time-using-gitlab)__ before anything else.
|
|
|
> If this is your first time using Git or simply using this GitLab server, please read through __[First time using GitLab](#first-time-using-gitlab)__ before anything else.
|
|
|
|
|
|
If you are looking for GitLab's docs, they are **[here.](https://git.cs.sun.ac.za/help/#gitlab-documentation)**
|
|
|
|
... | ... | @@ -15,10 +15,10 @@ The above is a very good summary, and you are encouraged to have it open or prin |
|
|
|
|
|
|
|
|
### Simple Git Flow
|
|
|
1. `git pull` to bring changes from GitLab to the local repo.
|
|
|
2. Make changes to your local files in the repo.
|
|
|
2. `git add` files to the Index (staging area).
|
|
|
2. `git commit` to move changes from the Index to a local commit.
|
|
|
1. `git pull` to bring changes from GitLab to the local repository.
|
|
|
2. Make changes to your local files in the repository.
|
|
|
2. `git add` files to the index (staging area).
|
|
|
2. `git commit` to move changes from the index to a local commit.
|
|
|
2. `git push` to send local changes to GitLab.
|
|
|
|
|
|
|
... | ... | @@ -28,8 +28,8 @@ The above is a very good summary, and you are encouraged to have it open or prin |
|
|
|
|
|
Command | Effect
|
|
|
--- | ---
|
|
|
`git config --global user.name "YOUR_USERNAME"` | Setup your name for your commits.
|
|
|
`git config --global user.email "YOUR_EMAIL"` | Setup the email address for your commits.
|
|
|
`git config --global user.name "YOUR_USERNAME"` | Set up your name for your commits.
|
|
|
`git config --global user.email "YOUR_EMAIL"` | Set up the email address for your commits.
|
|
|
`git config --global color.ui auto` | Enable some colourful git output.
|
|
|
`git config --global core.editor "gedit -w -s" ` | Set commit message editor to `gedit`. Simple GUI editor.
|
|
|
`git config --global core.editor "vim" ` | Set the default commit message editor to `vim`.
|
... | ... | @@ -40,19 +40,19 @@ Command | Effect |
|
|
--- | ---
|
|
|
`git pull` | Fetch the latest commits from the GitLab server and update your local repository.
|
|
|
`git status` | Show the current status of the local working tree.
|
|
|
`git diff <file or folder>` | Show changes from the file or all files if none specified.
|
|
|
`git add <file or folder>` | Add the specific file or folder to the staging area.
|
|
|
`git diff <file or directory>` | Show changes from the file or all files if none specified.
|
|
|
`git add <file or directory>` | Add the specific file or directory to the staging area.
|
|
|
`git commit` | Move the changes from the staging area to `HEAD` on your local machine
|
|
|
`git push` | Send the commits on your local machine to the GitLab server
|
|
|
`git reset <file or folder>` | Un-stage changes to a file that have been git added. Local changes kept.
|
|
|
`git checkout -- <file or folder>` | Replaces the changes in file with the last content in HEAD. Local changes removed!
|
|
|
` git reset --hard origin/master ` | Replaces **all** local changes with the server version. Local changes destroyed!
|
|
|
`git reset <file or directory>` | Un-stage changes to a file that have been git added. Local changes are kept.
|
|
|
`git checkout -- <file or directory>` | Replaces the changes in file with the last content in `HEAD`. Local changes are removed!
|
|
|
` git reset --hard origin/master ` | Replaces **all** local changes with the server version. Local changes are destroyed!
|
|
|
|
|
|
|
|
|
## First time using GitLab
|
|
|
This section is aimed towards first time users of both Git and this instance of GitLab.
|
|
|
|
|
|
### What is `git` and GitLab?
|
|
|
### What is Git and GitLab?
|
|
|
Let's get this info from git's website:
|
|
|
> "[Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.](https://git-scm.com/)"
|
|
|
|
... | ... | @@ -62,7 +62,7 @@ Then from the Wikipedia page about GitLab: |
|
|
For you, as a student, this means you will
|
|
|
1. Have at least have one backup of your code in a safe place, provided you push your local changes back to the CS GitLab server,
|
|
|
2. Have version history of all your changes, provided your pushed each change to the server,
|
|
|
2. Learn how to use version control in order to help prepare you for the working world,
|
|
|
2. Learn how to use version control to help prepare you for the working world,
|
|
|
3. Be able to safely submit and track your code, with the over-site of the lecturers and demis.
|
|
|
|
|
|
**NOTE:** Always have a number of *safe* and *secure* backups of your code. GitLab should house one of a few copies of your projects.
|
... | ... | @@ -74,14 +74,14 @@ For you, as a student, this means you will |
|
|
When in doubt, ask your lecturer.
|
|
|
|
|
|
### Login
|
|
|
GitLab has been setup such that you can login with your Stellenbosch University credentials.
|
|
|
GitLab has been set up such that you can log in with your Stellenbosch University credentials.
|
|
|
|
|
|
1. Click the **Sign In / Register** button at the top corner, or **[click here](https://git.cs.sun.ac.za/users/sign_in)** to open the login page in a new tab.
|
|
|
2. Now click the **US Single Sign-On button** encircled in red in the below image.
|
|
|
|
|
|

|
|
|
|
|
|
3. You will be re-directed to the University single sign on system to login.
|
|
|
3. You will be re-directed to the University single sign on system to log in.
|
|
|
|
|
|
Congratulations! You should now be logged in. You won't be able to create any projects or groups as an undergraduate, but if you are a postgraduate, you can request permissions for this.
|
|
|
|
... | ... | @@ -132,7 +132,7 @@ Let's get your code from the server to your local machine. |
|
|
|
|
|

|
|
|
|
|
|
3. Open a terminal and use "cd" to **c**hange **d**irectory to where you would like to store your code. For example, below I create a new directory in my home folder called "git", I then "cd" into that directory.
|
|
|
3. Open a terminal and use "cd" to **c**hange **d**irectory to where you would like to store your code. For example, below I create a new directory in my home directory called "git", I then "cd" into that directory.
|
|
|
```
|
|
|
# "~/" is a shortcut for your home directory
|
|
|
$ mkdir ~/git
|
... | ... | @@ -154,14 +154,14 @@ Let's get your code from the server to your local machine. |
|
|
Resolving deltas: 100% (215/215), done.
|
|
|
````
|
|
|
|
|
|
If you have successfully gotten your code onto your local PC, well done! You should see a new folder within the directory you created with the same name as your project name.
|
|
|
If you have successfully gotten your code onto your local PC, well done! You should see a new directory within the directory you created with the same name as your project name.
|
|
|
|
|
|
Otherwise, if something went wrong, make a note of the error you encountered and ask a demi for help.
|
|
|
|
|
|
#### Make a local change
|
|
|
Let's create a file in your git folder and see how this change is shown in git.
|
|
|
Let's create a file in your git directory and see how this change is shown in git.
|
|
|
|
|
|
1. First "cd" into your newly cloned repo. For example following from above:
|
|
|
1. First "cd" into your newly cloned repository. For example following from above:
|
|
|
````bash
|
|
|
$ cd ~/git/netbot/
|
|
|
````
|
... | ... | @@ -177,7 +177,7 @@ Let's create a file in your git folder and see how this change is shown in git. |
|
|
$ ls
|
|
|
fred.txt
|
|
|
````
|
|
|
3. Now let's ask git what has changed in the repo with "git status":
|
|
|
3. Now let's ask git what has changed in the repository with "git status":
|
|
|
````
|
|
|
$ git status
|
|
|
On branch master
|
... | ... | @@ -190,7 +190,7 @@ Let's create a file in your git folder and see how this change is shown in git. |
|
|
|
|
|
nothing added to commit but untracked files present (use "git add" to track)
|
|
|
````
|
|
|
We see that there is a file called "fred.txt" that is not yet in the Index, or in the repo.
|
|
|
We see that there is a file called "fred.txt" that is not yet in the index, or in the repository.
|
|
|
4. Let's do as suggested and add the file with `git add fred.txt`.
|
|
|
5. If we `git status` again we see:
|
|
|
````
|
... | ... | @@ -264,5 +264,5 @@ You should now be able to manage and contribute to your project! Good luck, and |
|
|
## Links and Videos
|
|
|
Link | Description
|
|
|
--- | ---
|
|
|
[git - the simple guide](http://rogerdudler.github.io/git-guide/) | A short but decent guide. Helpful if you want to setup on your own PC.
|
|
|
[git - the simple guide](http://rogerdudler.github.io/git-guide/) | A short but decent guide. Helpful if you want to set up on your own PC.
|
|
|
[RW244 Documentation](http://cs.sun.ac.za/rw244/program/#documentation) | Willem Bester's website, includes many helpful links. |
|
|
\ No newline at end of file |