INDEX
2023-10-03 19:00 - How can I run gitlab in docker? What is there to learn from it? Need to set up variables and "engine" - # Use current folder for container export GITLAB_HOME=$(pwd) mkdir data logs config # Download and run gitlab docker run --detach --hostname gitlab.example.com \ --publish 443:443 --publish 80:80 --publish 22:22 \ --name gitlab \ --volume $GITLAB_HOME/config:/etc/gitlab \ --volume $GITLAB_HOME/logs:/var/log/gitlab \ --volume $GITLAB_HOME/data:/var/opt/gitlab \ --shm-size 256m gitlab/gitlab-ee:latest # Track progress (takes a long time) docker logs -f gitlab Oh so docker compose lets you run complex docker commands from a yml file. So I can prewrite all those volume links in some config and run "docker compose up" Okay I have no idea if this is live yet - the logs seem to keep going # Edit the gitlab config file sudo docker exec -it gitlab editor /etc/gitlab/gitlab.rb # Get initial password for "root" user sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password # Now log in as that user on "localhost" Will look around enterprise version but apparently community you do "gitlab-ce" How can I import projects from github? http://localhost/admin/application_settings/general#js-import-export-settings Can I import say yt-dlp into gitlab? git clone https://github.com/yt-dlp/yt-dlp.git # In the repo, try to add
2024-01-18 - Gitlab Need to get all my code uploaded to some repository so going to try gitlab Made an account - made cs_net/misc_blogcode - seems to have a basic repo What I really need to work out is managing a repo locally and then uploading git init # Ran this in ./code folder - need to gitignore some files # nginxredis/.gitignore (per project gitignore?) nginx/html/* reids/data/* git add nginxredis/.gitignore git add * # Didn't work before due to redis data file permissions git commit -m "Nginxredis" # This is actually what creates the first branch # Also to set the prefix for docker compose containers set "name: NAME" at the top git remote add origin git@gitlab.com:cs_net/misc_blogcode.git git push -u origin master # Don't have permission. git config --list # Show current user info (defined in ~/.gitconfig) https://gitlab.com/-/profile/keys - need to set ssh keys here mkdir -p ~/.ssh/gitlab; ssh-keygen -b 4096 -f ~/.ssh/gitlab/gitlab # Then put in a password cat ~/.ssh/gitlab/gitlab.pub # Copy public code (can ignore USER@HOST) onto gitlab webpage # ~/.ssh/config (add here to link refer to your keys as "gitlab") Host gitlab gitlab.com Hostname gitlab.com User git IdentityFile ~/.ssh/gitlab/gitlab # METHOD PEOPLE SAY TO USE eval "$(ssh-agent -s)"; ssh-add ~/.ssh/id_rsa # Run ssh agent and add keys ssh-add -l # List ssh keys in agent I realise now gitlab uses "main" branch so I wonder if I can edit that and undo it Actually easier to just clear the git folder and start again In https://gitlab.com/cs_net/misc_blogcode/-/branches press 3dots on master and delete it rm -rf .git # Delete the git folder git config --global init.defaultBranch main # Just for convenience, set it globally git config --global user.email ... # Do same for user.name git init; git add *; git commit -m "Nginxredis" git remote add origin git@gitlab.com:cs_net/misc_blogcode.git git push -u origin main # This fails as repo has a README file git pull --rebase origin main # Essentially changes history of current repo to match other git push -u origin main # Now can push changes to gitlab main repo directly # Delete readme rm README.md; git add README.md; git commit -m "Delete readme"; git push Okay let's try this for the blog content too. New project: code_blog (without a README) - repeat basic: init, remote, add, commit, push # .gitignore (as I also only want certain files archive/ code/ html/ Okay now I have everything backed up on gitlab as a proper git repo. Didn't know gitlab also had an editor built into it - impressive So essentially I have /blog and /blog/code as separate git repos (with code/ ignored in blog) I wonder what happens if I copy the whole repo and allow it to also pick up the code repo It warns you about adding a submodule. I'll try: git restore --staged code # Remove it from tracking git submodule add git@gitlab.com:cs_net/misc_blogcode.git code # Creates .gitmodules Seems like it just tracks a specific change in the git repo - so you have to keep updating it Not really worth the work honestly so going to try to remove it. git submodule deinit -f code # This does delete the files too git rm -r code; rm .gitmodules; git add .gitmodules # Remove from git I've done this on a copy of my repo so going to backup code repo and try to merge main But instead of rebasiing it might make more sense to just copy to another branch git checkout -b Jan18; git branch # Checkout branch and see if I did it right git add *; git commit -m "Minor changes to notes on git" git push -u origin Jan18 # Have to be very specific Now I have 2 branches I need to merge them - can I do this in CLI? https://docs.gitlab.com/ee/user/project/push_options.html - even with just git git push -o merge_request.create -o merge_request.target=main # from Jan18 branch I couldn't type during that cause it was rewriting the branch I'm in git checkout Jan18 # Went in to Jan18 git push -o merge_request.create -o merge_request.target=main git checkout main; git branch -d Jan18; git pull # Move, delete branch, pull new details Still not convinced these are in sync so going to close this, save everything, push and pull Okay everything syncronised now. Seems like I merged a branch without deleting then remerged. I think for safety also I'll move the code repo to outside the blog (as v2.1-code) Probably best I leave merges to in-browser - need some visual element So whole process is this: pull, checkout new branch, write code, push, merge Could probably do without merges if you unprotect main and just do "push -fu" Also "git reset" is undo for "git add ."