Difference between revisions of "Git cheat sheet"

From Simson Garfinkel
Jump to navigation Jump to search
m
 
(One intermediate revision by the same user not shown)
Line 47: Line 47:
 
     git merge uckelman/master
 
     git merge uckelman/master
  
 +
==Submodules!==
 +
Submodules are complicated. . It's important to remember that a parent module pegs to a particular submodule commit point, not to a branch.  The parent module does not automatically get the updates when the submodule is updated. This allows the authors of the submodule to do work without worry about breaking parents until the parents actually update their submodules. In this way, they work like versioned libraries.
 +
 +
Here are some recommended readings:
 +
 +
Documentation:
 +
* https://git-scm.com/book/en/v2/Git-Tools-Submodules
 +
* https://www.atlassian.com/git/tutorials/git-submodule
 +
 +
Short article:
 +
* https://github.blog/2016-02-01-working-with-submodules/
 +
 +
Longer Tutorial:
 +
* https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407
  
 
==References==
 
==References==

Latest revision as of 12:43, 24 June 2020

Origin info

Initial checkout:

  git clone <url> --recursive

change origin (useful if you cloned from a github http: but want to save it with a git@github.com...)

  git config remote.origin.url git@github.com...

Change origins for current and all submodules:

  git config -e

Make a signed tag and push to github

 git tag -u 'Simson L. Garfinkel <simsong@acm.org>' -s tcpflow-1.2.7 -m 'Release 1.2.7'
 git push --tags


Pull changes

From a forked repository's upstream. First we need to add 'upstream' as a name for a remote URL:

 git remote add upstream https://github.com/<<FOOBAR>>

Now we need to fetch the changes and merge them in:

 git fetch upstream        # fetches any new changes from original repository
 git merge upstream/master  # merges any changes fetched into your working files

This can be done as a single operation:

 git pull upstream/master

If there are local changes:

  • Resolve the conflicts
  • Note which conflicts you have resolved with git add conflictname.
  • commit your changes
  • push them to your origin/master:
 git push 


Differencing

  git diff HEAD  # should never produce output because HEAD is always the checked out commit
  git diff origin/master # Difference between you and the master
  git log origin/master  # Report what the differences are

Compare with a remote fork and take changes

(in this case, with

   git remote add uckelman https://github.com/uckelman/bulk_extractor.git
   cat .git/config 
   git fetch uckelman
   git diff uckelman/master
   git diff master uckelman/master 
   git merge uckelman/master

Submodules!

Submodules are complicated. . It's important to remember that a parent module pegs to a particular submodule commit point, not to a branch. The parent module does not automatically get the updates when the submodule is updated. This allows the authors of the submodule to do work without worry about breaking parents until the parents actually update their submodules. In this way, they work like versioned libraries.

Here are some recommended readings:

Documentation:

Short article:

Longer Tutorial:

References

[[Category::Cheat Sheets]]