Tech/OSS/Git

From lathama
< Tech‎ | OSS
Jump to navigation Jump to search

Tips and Howto

Setup and Config

Example setup using vim.tiny

git config --global core.editor "vim.tiny"
git config --global -e

Config file should look like this after you configure your name and email:

# This is Git's per-user configuration file.
[user]
# Please adapt and uncomment the following lines:
       name = John Doe
       email = jd@example.com
[core]
       editor = vim.tiny


Correct Author in last commit

I have this issue way to often

git commit --amend --no-edit --reset-author

Squashing

Sadly there are too many ways to squash in Git now. Old method from my personal notes is:

Select the last few commits you want to join as one
git rebase -i HEAD~3
In the editor that started select the commits after the desired commit you wish to squash by using the word squash or fixup and save. Then you can push.
git push origin

Accounts

https://lathama.net/git/lathama

Gitea

https://gitea.io/en-US/

Install and note the version in this example is 1.3.2 and maybe some day there will be a stable branch/tag.

adduser git
su git
cd /home/git
mkdir gitea
wget -O gitea https://dl.gitea.io/gitea/1.5.3/gitea-1.5.3-linux-amd64
chmod +x gitea

Use https://github.com/go-gitea/gitea/blob/master/contrib/systemd/gitea.service for

/etc/systemd/system/gitea.service

Apache Proxy via

 <Proxy *>
  Order allow,deny
  Allow from all
 </Proxy>
 ProxyPreserveHost On
 ProxyRequests off
 ProxyPass /git http://127.0.0.1:3000
 ProxyPassReverse /git http://127.0.0.1:3000

In /home/git/gitea/custom/config/app.ini limit to localhost like:

[server]
PROTOCOL         = http
DOMAIN           = lathama.net
HTTP_ADDR        = 127.0.0.1
HTTP_PORT        = 3000
ROOT_URL         = https://lathama.net/git/

In the app.ini you can set many things like https://docs.gitea.io/en-us/config-cheat-sheet/ and example at https://raw.githubusercontent.com/go-gitea/gitea/master/custom/conf/app.ini.sample eg

APP_NAME = Lathama Git Server

Then we just need to enable and start/restart services. (I use restart a lot in the case I had already started it.)

systemctl reload apache2
systemctl enable gitea
systemctl restart gitea

Hooks

Need to add examples of various things like Tech/HowTo/Deployment with Git Hooks

Resources