Change Windows mingw64 command line window text size[1]

Go to the options menu by clicking the top-left window icon button menu.

Change text size.

Click save.

A file is created in

~/.minttyrc

which makes the change permanent.

Install

SMTP setup[2]

Edit the file:

/etc/gitlab/gitlab.rb

and add relevant SMTP details similar to:

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.server"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "smtp user"
gitlab_rails['smtp_password'] = "smtp password"
gitlab_rails['smtp_domain'] = "example.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'

I inspected my SMTP settings in a known-good mail client (Thunderbird) Then reconfigure Gitlab by executing:

gitlab-ctl reconfigure

Generate SSH keys to apply to a Gitlab account[3]

Run ssh-keygen to generate the key (on the server).

ssh-keygen -t ed25519 -C "<comment>"

The comment is included in the .pub file that’s created. You may want to use an email address for the comment. Output similar to the following is displayed:

Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/user/.ssh/id_ed25519):

Accept the suggested filename and directory, unless you are generating a deploy key or want to save in a specific directory where you store other keys.

Specify a passphrase.

A confirmation is displayed, including information about where your files are stored. A public and private key are generated. Copy the public key to your Gitlab account (i.e. in the web interface). https://docs.gitlab.com/ee/user/ssh.html#add-an-ssh-key-to-your-gitlab-account

Optimising for small server[4]

Edit:

/etc/gitlab/gitlab.rb

Note that there are many more options to try in the reference. These massively improved my situation:

puma['worker_processes'] = 0
sidekiq['max_concurrency'] = 10
prometheus_monitoring['enable'] = false

Then reconfigure Gitlab by executing:

gitlab-ctl reconfigure

Convert an existing VS solution folder into a git repo and create a new gitlab project and upload it[5]

Use the git bash interface and enter commands like:

cd "C:\Users\dave\source\repos\myWickedProject"
git init
nano .gitignore
    --> add line: *.vsidx
git add .
git checkout -b master
git commit -m "Initial commit from cmdline"
git config --global http.proxy ''
git push --set-upstream https://myscmserver.com/dave/myWickedProject.git master
cd "c:\Users\Administrator\source\repos\Gcode" && git init && echo "*.vsidx" > .gitignore && git add . && git checkout -b master && git commit -m "Initial commit from cmdline" && git config --global http.proxy '' && git push --set-upstream https://scm.server.co.uk/dave/gcode.git master

No need to create a blank project first.

Fix repos

git fsck
git gc

Fixing SSL problems[6]

Reason

This problem is occuring because git cannot complete the https handshake with the git server were the repository you are trying to access is present.

Solution

Steps to get the certificate from the github server

  1. Open the github you are trying to access in the browser
  2. Press on the lock icon in the address bar > click on 'certificate'
  3. Go to 'Certification Path' tab > select the top most node in the hierarchy of certificates > click on 'view certificate'
  4. Now click on 'Details' and click on 'Copy to File..' > Click 'Next' > Select 'Base 64 encoded X509 (.CER)' > save it to any of your desired path.

Steps to add the certificate to local git certificate store

  1. Now open the certificate you saved in the notepad and copy the content along with --Begin Certificate-- and --end certificate--
  2. To find the path were all the certificates are stored for your git, execute the following command in cmd. git config --list
  3. Check for the key 'http.sslcainfo', the corresponding value will be path.

Note: If u can't find the key http.sslcainfo check for Git's default path: C:\Program Files\Git\mingw64\ssl\certs

  1. Now open 'ca-bundle.crt' present in that path.

Note 1 : open this file administrator mode otherwise you will not be able to save it after update. (Tip - you can use Notepad++ for this purpose) Note 2 : Before modifying this file please keep a backup elsewhere.

  1. Now copy the contents of file mentioned in step 1 to the file in step 4 at end file, like how other certificates are placed in ca-bundle.crt.
  2. Now open a new terminal and now you should be able to perform operations related to the git server using https.

Tips

Temporarily switch to a different commit[7]

If you want to temporarily go back to it, fool around, then come back to where you are, all you have to do is check out the desired commit:

<# This will detach your HEAD, that is, leave you with no branch checked out:
git checkout 0d1d7fc32

Or if you want to make commits while you're there, go ahead and make a new branch while you're at it:

git checkout -b old-state 0d1d7fc32

To go back to where you were, just check out the branch you were on again. (If you've made changes, as always when switching branches, you'll have to deal with them as appropriate. You could reset to throw them away; you could stash, checkout, stash pop to take them with you; you could commit them to a branch there if you want a branch there.)

Reverting Working Copy to Most Recent Commit

To revert to the previous commit, ignoring any changes:

git reset --hard HEAD

where HEAD is the last commit in your current branch

Suppress LF/CR Warning

Globally:

git config --global core.autocrlf input

Per Project:

git config core.autocrlf false

Cheat sheet

10 Most Useful Git Commands

Command Purpose Example
git status Show working tree and staging state. git status
git add Stage changes. git add file.csgit add .
git commit Create a commit. git commit -m "Fix login bug"
git log View commit history. git log --oneline --graph --decorate --all
git diff Show changes. git diffgit diff --staged
git switch Change branches. git switch feature/authgit switch -c feature/auth
git pull Fetch and merge/rebase from remote. git pull
git push Upload commits. git push origin master
git restore Discard or unstage changes. git restore file.csgit restore --staged file.cs
git branch List/create/delete branches. git branchgit branch feature/api

Commands worth memorising

  1. Show concise status

git status -sb

  1. Stage everything

git add .

  1. Stage interactively

git add -p

  1. Commit

git commit -m "Message"

  1. Amend previous commit

git commit --amend

  1. Pretty history

git log --oneline --graph --decorate --all

  1. What changed?

git diff git diff --staged

  1. Create and switch branch

git switch -c feature/foo

  1. Switch back

git switch master

  1. Update local branch

git pull

  1. Publish branch

git push -u origin feature/foo

  1. Discard local changes to a file

git restore file.cs

  1. Unstage a file

git restore --staged file.cs

Three commands that save the most time

  1. Find which commit changed a line

git blame file.cs

  1. Search commit history

git log --grep="authentication"

  1. See what happened to a file

git log --follow -- file.cs

Safe "undo" commands

Task Command
Unstage a file git restore --staged file
Discard edits git restore file
Amend last commit git commit --amend
Revert a commit (without rewriting history) git revert <commit>

Useful aliases

These cover the vast majority of day-to-day Git work: inspecting state, staging, committing, reviewing history, branching, synchronising with remotes, and safely undoing local changes.

References