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 [2026/06/14 09:08] – [Merge] jhagstrandgit [2026/06/16 00:13] (current) – [diff] jhagstrand
Line 222: Line 222:
 ==== Squash Merge ==== ==== Squash Merge ====
  
-  Squash merge the feature branch this stages all the changes but doesn't commit yet +The --squash option, the merge command does not really do a merge.  Instead it copies all of the changed files from the feature branch to the master branch.  So now you do a single commit on the master branch, write a commit message summarizing all the individual commits made on the feature branch. 
-  git merge --squash animate+ 
 +This is one of the ways to collapse a developer's many chaotic commits into a single nice-looking well-thought-out commit.  
 + 
 +  # Make sure you're on the branch you want to merge into 
 +  git checkout master 
 +   
 +  # merge the feature branch with --squash option 
 +  this stages all the file changes into the master branch 
 +  git merge --squash feature 
 +   
 +  # ask for status now and you'll see all the changes ready for commit 
 +  git status
      
   # now commit   # now commit
-  git commit -m "feat: add animate command"+  git commit -m "feat: add feature command"
      
   # delete the feature branch   # delete the feature branch
-  git branch -D animate+  git branch -D feature
      
-  # for fun do a log all between these commands to what's going on +  # for fun do a log all between these commands to see what's going on 
   git log --all --oneline -15 --graph --decorate   git log --all --oneline -15 --graph --decorate
  
Line 262: Line 273:
 ====diff==== ====diff====
  
-Use diff to find the differences between two branches or between two files.\\ +Use diff to find the differences between two commits.\\
-Note that there is a big difference between .. and ... between the two commit designations.\\ +
-Also the two hyphens -- can go before or after the filename and that alters the output.\\+
  
-  git diff master...featurebranch  # compare two branches +  git diff 1bde095 b0ba90d   # compare two commits 
-   +  git diff master sidebar    # compare two branches 
-  git diff 1bde095..b0ba90d -- html/js/hud.js  # compare two different commits of a file+  git diff master sidebar hud.js  # compare two versions of a file
  
 By default diff compares all of the currently modified files. By default diff compares all of the currently modified files.
Line 278: Line 287:
 Additional options. Additional options.
  
 +  git diff master sidebar --stat   # show filenames and counts only
   git diff -U0 # do not display context   git diff -U0 # do not display context
-   
-  git diff -w # ignore whitespace 
-  git diff -w --word-diff-regex=[^[:space:]] # ignore whitespace additional 
  
 +Whitespace.\\
 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
  
 +  git diff -w # ignore whitespace
 +  git diff -w --word-diff-regex=[^[:space:]] # ignore whitespace additional
  
-====log====+Dots.\\ 
 +If both master and sidebar have changed, and you want to see only differences in sidebar, use three dots.  (This is a shortcut to naming the commit specifically.)\\ 
 +Warning! Two dots vs three dots makes a difference, and the difference is reversed in git diff vs git log.\\
  
-git log+  git diff master sidebar poker.js  # compare changes from latest master to latest sidebar 
 +  git diff master..sidebar poker.js  # same as no dots 
 +  git diff master...sidebar poker.js  # not latest master but master when sidebar branched
  
-git log --oneline -10+Double hyphens.\\ 
 +I don't know why this is used.\\
  
-git log --oneline --graph # shows a hierarchy of branches+  git diff master sidebar hud.js 
 +  git diff master sidebar -- hud.js 
 +  git diff master sidebar hud.js -- 
 + 
 +====log====
  
 +  git log
 +  git log master   # show log for one branch
 +  git log --oneline -10  # default to currently checked out branch
 +  git log --all --oneline --graph --decorate  # all branches, graph hierarchy
 +  git log --oneline -10     # topmost n lines
 +  git log --all --pretty=fuller
 ==== interactive rebase ==== ==== interactive rebase ====
  
git.1781442497.txt.gz · Last modified: 2026/06/14 09:08 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