This is an old revision of the document!
1. Go to the directory you want to clone the repo to
2. Go to the repo in Gitlab and copy the ssh link:
git@git:protea/protea_database.git
3. Note that git should be pointing to scp and not lengau, therefore in my .ssh/config file git2 points to scp so I use git clone git@git2:protea/protea_database.git:
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb $ git clone git@git2:protea/protea_database.git Cloning into 'protea_database'... Enter passphrase for key '/c/Users/BBarsch/.ssh/id_dsa': remote: Enumerating objects: 425, done.
Passphrase was Csir20…
4. Open your IDE, using sublime, and make changes to the code.
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb $ cd protea_database/ BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) $
5. Save the code and check the git status to make sure you are up-to-date:
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) $ git status On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) $
6. Next step is to push the code
1. Update, add, delete code and files. For demonstration we will just modify the README.md text for example.
Then go to that directory you did the clone from and hence the update and say git status:
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master)
$
2. this should show something is modified, and recommends you do git add . or git add <filename>:
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) $ git add README.md
4. Then do a commit git commit -m “commit comment”:
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) $ git commit -m "18-Feb-2021 Test Commit" [master b7ea92ab] 18-Feb-2021 Test Commit 1 file changed, 3 insertions(+)
5. And check with git status again that it has been added
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) $ git status On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean
6. Then lastly push the code to gitlab use git push:
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) $ git push Enter passphrase for key '/c/Users/BBarsch/.ssh/id_dsa': Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 12 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 323 bytes | 161.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 To git2:protea/protea_database.git b205ea3d..b7ea92ab master -> master
maybe asked for a passphrase, use Csir20… as its done through users.chpc or bio.chpc. Not sure if you can do this without a password as ssh-copy-id did not make a difference.
Next we need to update the user database
1. Update, add, delete code and files. For demonstration we will just modify the README.md text for example. Now change to another branch by using git checkout -b bb_new_branch:
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (master) $ git checkout -b bb_new_branch Switched to a new branch 'bb_new_branch'
2. Now check your status:
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (bb_new_branch)
$ git status
On branch bb_new_branch
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
3. Now add README.md and check the status:
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (bb_new_branch)
$ git add README.md
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (bb_new_branch)
$ git status
On branch bb_new_branch
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: README.md
4. Then make the commit:
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (bb_new_branch) $ git commit -m "Test push" [bb_new_branch 785e724a] Test push 1 file changed, 3 insertions(+)
5. Then push the code:
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (bb_new_branch)
$ git push
fatal: The current branch bb_new_branch has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin bb_new_branch
6. Note this is different to how you do it with master you have to upstream:
BBarsch@BBARSCH-NB1 MINGW64 /d/CSIR_Dev/git_userdb/protea_database (bb_new_branch) $ git push --set-upstream origin bb_new_branch Enter passphrase for key '/c/Users/BBarsch/.ssh/id_dsa': Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 12 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 311 bytes | 311.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 remote: remote: To create a merge request for bb_new_branch, visit: remote: http://git.chpc.ac.za/protea/protea_database/-/merge_requests/new?merge_request%5Bsource_branch%5D=bb_new_branch remote: To git2:protea/protea_database.git * [new branch] bb_new_branch -> bb_new_branch Branch 'bb_new_branch' set up to track remote branch 'bb_new_branch' from 'origin'.
Now when you try to merge on Gitlab:
1. Login in to the cluster (login2) by using the following command. (replace bbarsch with your username)
ssh bbarsch@lengau.chpc.ac.za
2. Then ssh to users (Password is P@…):
ssh users2.chpc.ac.za
3. Login as root user (superuser…note you need admin permission):
sudo su -
4. Connect to chpc:
su - chpc
5. Go to the user database directory:
cd protea_database/
6. Check the git status if any changes exist:
git status
7. Downloads commits, files, and refs from a remote repository into your local repo by using git fetch:
git fetch
8. Check if any local changes exist:
git stash
9. Pull any changes from the repo:
git pull
10. Pull any changes from submodules (helpdesk) linked to this repo:
git submodule update
11. Get back in to root user by logging out from chpc using:
ctrl+d
12. Restart the gunicorn service:
systemctl restart gunicorn.service
13. Start ngninx:
systemctl start nginx
14. Flush redis:
redis-cli flushall
15. Close the terminal and go to the users2 site on a browser to see changes:
users2.chpc.ac.za
- Note to do the same for usersdev you must tunnel in as its internal, use the command:
ssh -N -L 8888:usersdev.chpc.ac.za:80 scp.chpc.ac.za
- then go to localhost:8888