User Tools

Site Tools


git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
git [2023/05/08 18:01] – [Fixing a bug in its own branch] dblumegit [2025/07/08 16:13] (current) – [Building Git] dblume
Line 1: Line 1:
 ====== git ====== ====== git ======
 +
 +===== Building Git =====
 +
 +In Ubuntu, get some dev libs first:
 +
 +<code bash>
 +sudo apt-get install libssl-dev libcurl4-gnutls-dev gettext
 +</code>
 +There was [[https://lore.kernel.org/git/xmqq5xg2wrd1.fsf@gitster.g/|a security fix in 2.50.1]], so here we get that one:
 +<code bash>
 +git clone --filter=blob:none -b v2.50.1 --single-branch --no-tags https://github.com/git/git
 +# or: git clone --branch v2.50.1 --depth 1 https://github.com/git/git
 +# or even: wget https://www.kernel.org/pub/software/scm/git/git-2.50.1.tar.xz
 +
 +make prefix=$HOME/.local -j$(nproc)
 +make prefix=$HOME/.local install
 +</code>
 +
 +This will put git in ''$HOME/.local/bin/''
 +
 +===== Using Git =====
  
 Make the clone of the remote repository. Make the clone of the remote repository.
Line 24: Line 45:
   git@fake.github.com:project/project.git   git@fake.github.com:project/project.git
 </code> </code>
 +
 +Eventually, if you want to add another branch to a single-branch clone:
 +
 +  git remote set-branches --add origin another-branch
 +
 +Or to de-single-branch-ize a clone:
 +
 +  git remote set-branches origin "*"
 +
  
 ===== Creating a new remote repository from an existing local one ===== ===== Creating a new remote repository from an existing local one =====
Line 121: Line 151:
  
 <code> <code>
-git mergetool  # Bring up the vim 3-way diff+git mergetool (possibly with filename)  # Bring up the vim 3-way diff
  
-# +----------+-----------+--------------+ +# +----------+-----------+------------------+ 
-# |          | (common)              +# | (others) | (common) (my most recent) 
-# | LOCAL    | BASE      | REMOTE       +# | LOCAL    | BASE      | REMOTE           
-# +-------------------------------------+ +# +-----------------------------------------+ 
-# |                                     +# |                                         
-# | temp files with <<< ||| >>> diffs   +# | temp file with <<< ||| >>> diffs        
-# +-------------------------------------+ +# +-----------------------------------------+
-#+
  
 +git commit -a -m "Resolved merge conflict"
 +</code>
 +
 +Possibly keep rebasing.
 <code> <code>
 +git rebase --continue
 +git pull
 +</code>
  
 ====== Alternative to Rebasing: Stash, Pull, Unstash ====== ====== Alternative to Rebasing: Stash, Pull, Unstash ======
Line 195: Line 231:
 git$ cd testcode.git/ git$ cd testcode.git/
 testcode.git$ git init --bare testcode.git$ git init --bare
 +testcode.git$ git config pack.threads 8  # Otherwise clone might fail with "unable to create thread"
 </code> </code>
  
Line 209: Line 246:
 </code> </code>
  
-could've used gitweb but I used GitHub-like [[https://github.com/klaussilveira/gitlist|gitlist]] at http://git.dlma.com.+Options are: 
 + 
 +  * chose GitHub-like [[https://github.com/klaussilveira/gitlist|gitlist]] for https://git.dlma.com, because it works on my shared server. 
 +  * [[https://www.reddit.com/r/selfhosted/comments/13hxnf4/selfhosted_git_services_you_dont_need_a_huge/|cgit]] might work 
 +  * [[https://gogs.io/|gogs]] 
 +  * [[https://git-scm.com/book/en/v2/Git-on-the-Server-GitWeb|GitWeb]] (the one built-in.
  
 ====== Limit scope of huge repos ====== ====== Limit scope of huge repos ======
Line 229: Line 272:
  
 The submodule one is an optimization for the more general: The submodule one is an optimization for the more general:
 +<code bash>
 +git submodule update --recursive  # Add --init before --recursive on first time
 +</code>
 +
 +====== Submodules ======
 +
 +[[https://www.cyberdemon.org/2024/03/20/submodules.html|Demystifying git submodules]] is [[https://social.jvns.ca/@b0rk/112604915327918216|summarized by Julia Evans in a 'zine page here]].
 +
 +Cloning a repo doesn't download its submodules. After cloning, run:
 +
 +<code bash>
 +git submodule update --init --recursive
 +</code>
 +
 +Git pull and checkout don't update submodules. To actually update them, you have to run the following every time you switch branches or pull.
 +
 <code bash> <code bash>
 git submodule update --recursive  # Add --init before --recursive on first time git submodule update --recursive  # Add --init before --recursive on first time
git.1683594104.txt.gz · Last modified: 2023/05/08 18:01 by dblume