Monday, September 27, 2021

Git unplugged notes

Git unplugged notes



Rebase issue

# If someone rebases on public branch, after pull all others could see:

Your branch and 'origin/branch1' have diverged,

and have 2 and 3 different commits each, respectively.

Solution

git fetch origin

git reset --hard origin/main

src stackoverflow



Rebase issue

Your branch is ahead of 'origin/master' by 3 commits

Solution

git fetch -p # clean up local branches

git pull --rebase # pull and rebase my local commits on top of incoming

Better solution (unchecked)

Step 1 : git checkout branch1

Step 2 : git pull -s recursive -X theirs # merge strategies

Step 3 : git reset --hard origin/branch1



Rebase issue explained (long)

git rev-list --count --left-right branch1...upstream

git rev-list --count --left-right origin/master...HEAD

*

# to see if the local repository is ahead, push needed:

git rev-list origin..HEAD

# to see if the local repository is behind, pull needed:

git rev-list HEAD..origin

# if you have numbers for both, then the two repositories have diverged:

git rev-list --count --left-right origin/master...HEAD

src: stackoverflow

src: https://stackoverflow.com/a/40990959

src-long: https://stackoverflow.com/a/66981730



# squash - reset soft:

#git reset --soft master

git reset --soft origin/master

git add -A

git commit

git push --force



# squash - reset to merge-base:

git checkout branch1

git reset $(git merge-base master $(git branch --show-current))

git add -A

git commit

git push --force

# src: https://stackoverflow.com/questions/25356810/git-how-to-squash-all-commits-on-branch

# Note: git merge-base branch2 branch3



Squash

# squash - merge squash:

git checkout origin/master

git merge --squash origin/branch1

git commit

git push --force



Git branch_name vs refs

git show-ref origin/main

1. If $GIT_DIR/<refname> exists, that is what you mean (this is usually useful only for HEAD, FETCH_HEAD, ORIG_HEAD, MERGE_HEAD and CHERRY_PICK_HEAD);

2. refs/<refname> if it exists;

3. refs/tags/<refname> if it exists;

4. refs/heads/<refname> if it exists;

5.  refs/remotes/<refname> if it exists;

6. refs/remotes/<refname>/HEAD if it exists.

src: stackoverflow.com

Long aside: how this all works (read only if sufficiently curious) :

src: stackoverflow.com



Git server repository (docker git repo)

Alpine Git client

JKarlos Docker Git server

Gogs and Podman Git server

Gogs Git server

Gogs by Pirates - GitHub like Git server

Gitea in Docker - demo - github

GitColony docker server - obsolete



Git server:

Google it:

https://www.google.com/search?q=gnu+gpl+git+server

Git server list - wiki:

https://en.wikipedia.org/wiki/Git#Git_server

Gerrit:

Home: https://www.gerritcodereview.com/

Wiki: https://en.wikipedia.org/wiki/Gerrit_(software)

GitOlite:

https://gitolite.com/gitolite/index.html

Wiki says: External projects like gitolite, which provide scripts on top of git software to provide fine-grained access control.

*

FLOSS:

Gogs

Gitea = fork of Gogs



Git Web interface self-hosted:

https://www.google.com/search?q=git+web+interface+self-hosted

Options – list – good overview:

https://www.cyberciti.biz/open-source/github-alternatives-open-source-seflt-hosted/

GitLab = web git, “Confluence” wiki, “Jira” tracker

https://gitlab.com/gitlab-org/gitlab-foss

Gitea – community fork of Gogs:

https://gitea.io/

Savannah = GNU = free software foundation (FSF)

http://savannah.gnu.org/projects/administration

GitBucket – Open source

https://github.com/gitbucket/gitbucket

Gogs - self hosted Git:

https://gogs.io/

*

Awesome Selfhosted:

https://github.com/awesome-selfhosted/awesome-selfhosted

GitWeb:

https://git-scm.com/book/en/v2/Git-on-the-Server-GitWeb

*

BitBucket.org

GitHub.com


Git web UI – including proprietary and closed-source:

https://www.slant.co/topics/1440/~best-self-hosted-web-based-git-repository-managers

https://www.slant.co/topics/425/~best-git-web-interfaces



No comments: