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 [2024/08/31 05:49] jhagstrandgit [2024/10/10 05:55] (current) – [worktree] jhagstrand
Line 5: Line 5:
 Written by Linus Torvalds to replace svn and cvs. Written by Linus Torvalds to replace svn and cvs.
  
 +todo:
 +  * streamline the submodule section
 +  * streamline the internals section
 +  * coordinate the "how-to" sections
 +  * coordinate workflow section with "projects:developer guide" section
 =====Overview===== =====Overview=====
  
Line 19: Line 24:
   * working copy - sometimes used to refer to the current worktree   * working copy - sometimes used to refer to the current worktree
   * workflow - the procedures and conventions used by a development team   * workflow - the procedures and conventions used by a development team
 +
 +More:
   * index - ?   * index - ?
   * HEAD - ?   * HEAD - ?
   * detached head - ?   * detached head - ?
 +  * commit-ish 
 +  * SHA-1 value 
 +  * HEAD 
 +  * refs 
 +  * branch = ref 
 +  * Three object types: blobs, trees, commits 
 +  * fourth: tags 
 +  * refs:  branch, tag, remote
  
 ====repository==== ====repository====
Line 105: Line 119:
 You can push, you can pull. You can push, you can pull.
 You cannot status, merge, commit, diff, etc, because these commands act on the paired worktree. You cannot status, merge, commit, diff, etc, because these commands act on the paired worktree.
 +
 +==== push vs pull ====
 +
 +git push - pushes commits from one repo to another\\
 +git pull - pulls changes and merges them into a local worktree
 +
 +if we wanted to do a pull, we could pull into webprod or webdev, then push from there to voycgit
 +
 +==== merge vs rebase ====
 +
 +if development is ongoing in the master branch
 +while some special feature development is going on in the feature branch
 +
 +when you eventually merge the feature back into master, do a merge, to maintain the true history
 +
 +in the the meantime, to bring master changes into the feature, do a rebase, 
 + handle the conflicts now, so the future feature merge will run without conflicts
 +
 +handle conflicts conflicts in the feature branch, not when attempting the final feature merge
 +
  
  
Line 165: Line 199:
 In .gitconfig, add  In .gitconfig, add 
 [core] whitespace = -trailing-space,-indent-with-non-tab,-tab-in-indent [core] whitespace = -trailing-space,-indent-with-non-tab,-tab-in-indent
 +
 +
 +===== superproject and submodule =====
  
 ====Add submodule to super-project==== ====Add submodule to super-project====
Line 173: Line 210:
  git submodule update --init    # init + update info in .git/config.  (You may also edit manually.)  git submodule update --init    # init + update info in .git/config.  (You may also edit manually.)
  git submodule foreach git pull origin master  # pull latest files for all submodules  git submodule foreach git pull origin master  # pull latest files for all submodules
 +====submodules====
  
  
-===== superproject and submodule =====+In the listings above jslib shows as an empty folder in the worktree,\\ 
 +and as a commit in the .git database.\\ 
 +That is the commit that was originally pulled into this super-project. 
 + 
 + 
 +git submodule update 
 +This gets the url from .git/config [jslib] section. 
 +And it gets the commit  
 +When we do a git 
 + 
 +==all-in-one== 
 +  git clone --recurse-submodules https:git.voyc.com/barecentral/layout 
 + 
 +Does the clone and then does a  
 +  git submodule update --init --recursive 
 + 
 + 
 +====Move a Superproject to a New GitServer==== 
 + 
 +For example, we recently moved from github to gitlab. 
 + 
 +A superproject contains submodules.\\ 
 +Each submodule is identified by name, path, url, and commit-ish.\\ 
 +You specify the name, path and url in the .gitmodules file.\\ 
 +Git retains the commit-ish in the database, as you can see with ''git ls-tree master''
 + 
 +**Step 1.**  manually edit the .gitmodules file.\\ 
 +Here we specify the new server url. 
 + 
 +**Step 2.**  ''git submodule init''\\ 
 +This copies the changes in .gitmodules into the .git/config file. 
 + 
 +**Step 3.** ''git submodule sync''\\ 
 +This changes the remotes in the submodules. 
 + 
 +**Step 4.**  ''git submodule update''\\ 
 +This pulls a version of submodule jslib into the jslib folder, \\ 
 +using the url found in .git/config and the jslib commit-ish found in the layer/.git database. 
 +This version may not be the latest, and therefore we continue with step 4. 
 + 
 +**Step 5.** ''git submodule foreach git pull origin master''\\ 
 +This pulls the latest commit from the jslib/.git. 
 + 
 +**Step 6.** Add, commit and push the layout superproject. 
 +  $ git status 
 +  modified:   .gitmodules 
 +  modified:   jslib (new commits) 
 +   
 +  git add . 
 +  git commit -m 'Pull latest submodules' 
 +  git push origin master
  
 +==== overview ====
 A superproject is one that has submodules. A superproject is one that has submodules.
 The submodules are listed in .gitmodules file of the superproject. The submodules are listed in .gitmodules file of the superproject.
Line 385: Line 474:
 ====Forking Workflow==== ====Forking Workflow====
 Fundamentally different than the other workflows discussed in this tutorial. Instead of using a single server-side repository to act as the “central” codebase, it gives every developer a server-side repository. This means that each contributor has not one, but two Git repositories: a private local one and a public server-side one.  Fundamentally different than the other workflows discussed in this tutorial. Instead of using a single server-side repository to act as the “central” codebase, it gives every developer a server-side repository. This means that each contributor has not one, but two Git repositories: a private local one and a public server-side one.
 +
 +===== Protocol =====
 +
 +Three choices: ssh, xttps, git.
 +
 +  $ git clone ssh://voyccom@az1-ss8.a2hosting.com:7822/home/voyccom/voycgit/jslib
 +  $ git clone xttps://gitlab.com/voyc/jslib
 +
 +The git protocol is a daemon that ships with git.  It is similar to ssh but has no authentication and no encryption.
  
  
 =====Web Access===== =====Web Access=====
 +
 ====HTML Interface==== ====HTML Interface====
 ^ product  ^  open source  ^ comment              ^ ^ product  ^  open source  ^ comment              ^
Line 398: Line 497:
 | github        15 |        31M | | github        15 |        31M |
 | gitlab         5 |        16M | | gitlab         5 |        16M |
- 
-==== Repository Clone Name Format ==== 
- 
-  $ git clone ssh://voyccom@az1-ss8.a2hosting.com:7822/home/voyccom/voycgit/jslib 
-  $ git clone xttps://gitlab.com/voyc/jslib 
- 
  
 =====.git Folder===== =====.git Folder=====
Line 498: Line 591:
   24cb5418f6fcc6d2ddd292593d412ec760b57028 Initial file load   24cb5418f6fcc6d2ddd292593d412ec760b57028 Initial file load
   69d88ec081a75a52b8b7661da0251325906de3b2 Initial commit   69d88ec081a75a52b8b7661da0251325906de3b2 Initial commit
- 
-====submodules==== 
- 
  
 In the listings above jslib shows as an empty folder in the worktree,\\ In the listings above jslib shows as an empty folder in the worktree,\\
 and as a commit in the .git database.\\ and as a commit in the .git database.\\
 That is the commit that was originally pulled into this super-project. That is the commit that was originally pulled into this super-project.
- 
- 
-git submodule update 
-This gets the url from .git/config [jslib] section. 
-And it gets the commit  
-When we do a git 
- 
- 
-====Move a Superproject to a New Server==== 
- 
-A superproject contains submodules.\\ 
-Each submodule is identified by name, path, url, and commit-ish.\\ 
-You specify the name, path and url in the .gitmodules file.\\ 
-Git retains the commit-ish in the database, as you can see with ''git ls-tree master''. 
- 
-**Step 1.**  manually edit the .gitmodules file.\\ 
-Here we specify the new server url. 
- 
-**Step 2.**  ''git submodule init''\\ 
-This copies the changes in .gitmodules into the .git/config file. 
- 
-**Step 3.**  ''git submodule update''\\ 
-This pulls a version of submodule jslib into the jslib folder, \\ 
-using the url found in .git/config and the jslib commit-ish found in the layer/.git database. 
-This version may not be the latest, and therefore we continue with step 4. 
- 
-**Step 4.** ''git submodule foreach git pull origin master''\\ 
-This pulls the latest commit from the jslib/.git. 
- 
-**Step 5.** Add, commit and push the layout superproject. 
-  $ git status 
-  modified:   .gitmodules 
-  modified:   jslib (new commits) 
-   
-  git add . 
-  git commit -m 'Pull latest submodules' 
-  git push origin master 
- 
-=== More === 
-What about ''git submodule update --init --recursive''\\ 
-What about ''git sync''?\\ 
- 
  
  
git.1725097789.txt.gz · Last modified: 2024/08/31 05:49 by jhagstrand

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki