Having a Github-Pro account (available for university students freely) to be able to create private repositories hosted on Github.
The solution stated here are with the https
github urls, if you want the
ssh
version, see the README_ssh.md file.
- With your Github-Pro account, create a new private repository, preferably with the same name as
the assignment you want to do in pair, for example
1-html-css
. This repository will have a clone url like the one belowhttps://github.com/student-A/1-html-css.git
- Add Student B as a collaborator on this repo, so that you can both access the newly created repo. To do so, go on the github page of the newly created repo, Settings->Manage Access->Invite a collaborator, and then insert the name of the github account Student B.
- Clone the official Github-Classroom repo. See the line below as an example.
git clone https://github.com/USI-Web-Atelier-2021/1-html-css-student-A.git
- Change the url settings of the local git repo so that now it pulls from the
newly created common private repository (you can do either with
https
orssh
).To check if you have completed this step successfully try the commandgit remote set-url origin https://github.com/student-A/1-html-css.git
and the output should something likegit remote -v
origin https://github.com/student-A/1-html-css.git(fetch) origin https://github.com/student-A/1-html-css.git(push)
- Add back the official Github-Classroom repository (be careful to add your
own repo, and not the one of your teammate) as a push remote so that all
the changes made are stored in the official repo.
To check if you have completed this step successfully try the command
git remote set-url --add origin https://github.com/USI-Web-Atelier-2021/1-html-css-student-A.git
and the output should something likegit remote -v
origin https://github.com/student-A/1-html-css.git(fetch) origin https://github.com/student-A/1-html-css.git(push) origin https://github.com/USI-Web-Atelier-2021/1-html-css-student-A.git(push)
- Push the local repo to the newly created one
git push -u origin master
- Accept the invitation of Student A to collaborate on the newly created private repo (the invitation should be located in your USI email inbox).
- Clone the repo created by Student A
git clone https://github.com/student-A/1-html-css.git
- Add the official Github-Classroom repository (be careful to add your
own repo, and not the one of your teammate) as a push remote so that all
the changes made are stored in the official repo.
To check if you have completed this step successfully try the command
git remote set-url --add origin https://github.com/USI-Web-Atelier-2021/1-html-css-student-A.git
and the output should something likegit remote -v
origin https://github.com/student-A/1-html-css.git(fetch) origin https://github.com/student-A/1-html-css.git(push) origin https://github.com/USI-Web-Atelier-2021/1-html-css-student-B.git(push)
- Force a push so that your local repo is the same as the official repo
(in some cases the default branch is called
git push -fu origin master
main
, if the previous command failed, try to replacemaster
withmain
).
Now every time you want to upload your commits, you can just perform
git push
and all of them will be uploaded to both the Github-Classroom and the common repository.
- The process has to be repeated at every assignment.
- The process of having a pro-github account to have access to private repos can be a bit involved.
- There might be some plagiarism issues if a student doesn't setup the private repository correctly.