Difference between revisions of "Git notes"

From Wiki at Neela Nurseries
Jump to: navigation, search
(minor formatting)
m (add section "git inner workings", links to two of three Zvonimir Spajic tutorials)
Line 14: Line 14:
  
 
Following article / document collection of notes on version control software named <code>git</code>.  Worth noting at top of these notes is an nvie.com blog post about practical and widespread git branching strategy, at https://nvie.com/posts/a-successful-git-branching-model/.
 
Following article / document collection of notes on version control software named <code>git</code>.  Worth noting at top of these notes is an nvie.com blog post about practical and widespread git branching strategy, at https://nvie.com/posts/a-successful-git-branching-model/.
 
  
 
<!-- comment -->
 
<!-- comment -->
  
== [[#top|^]] How To Use Git ==
+
== [[#top|^]] Common Commands ==
 
<br />
 
<br />
 
Wanting to understand and use <code>git</code> better, here are some on-line references to <code>git</code> version control.  Noting here git reference at orga.cat, this reference well-written with lots of commands and concise explanations of each command.  This reference is first in list:
 
Wanting to understand and use <code>git</code> better, here are some on-line references to <code>git</code> version control.  Noting here git reference at orga.cat, this reference well-written with lots of commands and concise explanations of each command.  This reference is first in list:
 
  
 
Basic git commands:
 
Basic git commands:
Line 31: Line 29:
 
2020-05-06
 
2020-05-06
 
*  https://www.tutorialspoint.com/git/git_patch_operation.htm  Git patch commands, found by Joel Hart
 
*  https://www.tutorialspoint.com/git/git_patch_operation.htm  Git patch commands, found by Joel Hart
 
  
 
Atlassian article on Git's edit/stage/commit pattern of use <i>(Invoke `git add` to stage local file changes.)</i>:
 
Atlassian article on Git's edit/stage/commit pattern of use <i>(Invoke `git add` to stage local file changes.)</i>:
  
 
*  https://www.atlassian.com/git/tutorials/saving-changes
 
*  https://www.atlassian.com/git/tutorials/saving-changes
 
  
 
Setting up ssh key pairs for secure authentication:
 
Setting up ssh key pairs for secure authentication:
 
*  https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent . . . generate new key and add key to [https://linux.die.net/man/1/ssh-agent ssh-agent]
 
*  https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent . . . generate new key and add key to [https://linux.die.net/man/1/ssh-agent ssh-agent]
 
 
  
 
Why are my local changes getting lost?  Git commit-and-push-sequence not sufficient to transfer file changes to given git repository . . .
 
Why are my local changes getting lost?  Git commit-and-push-sequence not sufficient to transfer file changes to given git repository . . .
Line 48: Line 42:
 
*  [http://dont-be-afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html git stage, commit, push on command line]
 
*  [http://dont-be-afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html git stage, commit, push on command line]
 
*  [https://www.atlassian.com/git/tutorials/saving-changes git 'commit' akin to traditional 'save file', Subversion model versus Git model]
 
*  [https://www.atlassian.com/git/tutorials/saving-changes git 'commit' akin to traditional 'save file', Subversion model versus Git model]
 
  
 
Git references found while answering specific git task questions:
 
Git references found while answering specific git task questions:
Line 59: Line 52:
 
*  https://www.kernel.org/pub/software/scm/git/docs/git-diff.html
 
*  https://www.kernel.org/pub/software/scm/git/docs/git-diff.html
 
   $ git diff HEAD .
 
   $ git diff HEAD .
 
 
  
 
2022-01-10
 
2022-01-10
Line 74: Line 65:
 
   6  2008  history
 
   6  2008  history
 
</pre>
 
</pre>
 
  
 
Markdown and .md file formatting at Github
 
Markdown and .md file formatting at Github
Line 80: Line 70:
 
*  [https://guides.github.com/features/mastering-markdown/ Mastering markdown]
 
*  [https://guides.github.com/features/mastering-markdown/ Mastering markdown]
 
*  https://anvilproject.org/guides/content/creating-links
 
*  https://anvilproject.org/guides/content/creating-links
 
  
 
Git and Working with Remote Repositories
 
Git and Working with Remote Repositories
Line 87: Line 76:
 
*  [https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes git-scm dot com - book, English, version 2, "Working with Remotes"]
 
*  [https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes git-scm dot com - book, English, version 2, "Working with Remotes"]
 
</ul>
 
</ul>
 
  
 
Release tag creation and naming in Git
 
Release tag creation and naming in Git
  
 
*  https://git-scm.com/book/en/v2/Git-Basics-Tagging
 
*  https://git-scm.com/book/en/v2/Git-Basics-Tagging
 
 
  
 
<!-- comment -->
 
<!-- comment -->
Line 103: Line 89:
 
     $ git remote -v
 
     $ git remote -v
  
 +
<!-- comment -->
 +
 +
== [[#top|^]] Git Inner Workings ==
  
 +
Good trio of articles by Zvonimir Spajic, on `git` inner workings, how git works under the hood.  These tutorials also explain some important git terminology.  Among the git details presented here Zvonimir explains that git "sees" a developer's changes in three places:  working directory, staging directory and local repository.  The staging directory contains a particular version controlled project's git index file.  Staged but not committed changes are kept in this index file.
  
<!-- comment -->
+
<ul>
 +
*  { first konrad_126 git tutorial link not yet available }
 +
*  https://konrad126.medium.com/understanding-git-branching-2662f5882f9 . . . git branching
 +
*  https://konrad126.medium.com/understanding-git-index-4821a0765cf . . . git index file
 +
</ul>
 +
 
 +
<!-- odne komentar -->
  
 
== [[#top|^]] Git Terminology ==
 
== [[#top|^]] Git Terminology ==
Line 112: Line 108:
  
 
   *  https://git-scm.com/docs/git-rebase
 
   *  https://git-scm.com/docs/git-rebase
 
 
  
 
<!-- comment -->
 
<!-- comment -->
Line 225: Line 219:
 
<code>$ git tag -a &lt;tag_name&gt; -m "tagging message here" [optional_commit_hash]</code><br />
 
<code>$ git tag -a &lt;tag_name&gt; -m "tagging message here" [optional_commit_hash]</code><br />
 
</ul>
 
</ul>
 
  
 
<!-- comentario -->
 
<!-- comentario -->

Revision as of 18:35, 11 July 2023

-- 2017-12-04 Monday - somvaar - सोमवार--
Git Notes


^ OVERVIEW - अवलोकन

Following article / document collection of notes on version control software named git. Worth noting at top of these notes is an nvie.com blog post about practical and widespread git branching strategy, at https://nvie.com/posts/a-successful-git-branching-model/.


^ Common Commands


Wanting to understand and use git better, here are some on-line references to git version control. Noting here git reference at orga.cat, this reference well-written with lots of commands and concise explanations of each command. This reference is first in list:

Basic git commands:

2020-05-06

Atlassian article on Git's edit/stage/commit pattern of use (Invoke `git add` to stage local file changes.):

Setting up ssh key pairs for secure authentication:

Why are my local changes getting lost? Git commit-and-push-sequence not sufficient to transfer file changes to given git repository . . .

Git references found while answering specific git task questions:

  $ git diff HEAD .

2022-01-10 Commands in `git` to rename local and remote branch:

ejemplo - board `anda-m`:

  1  2003  git checkout andam-board-bring-up
  2  2004  git branch -m anda-m-board-bring-up
  3  2005  git branch
  4  2006  git push origin -u anda-m-board-bring-up
  5  2007  git push origin --delete andam-board-bring-up
  6  2008  history

Markdown and .md file formatting at Github

Git and Working with Remote Repositories

Release tag creation and naming in Git


^ Git Command Examples

On the local work station, to see from which remote git repository a working copy comes:

   $ git remote -v


^ Git Inner Workings

Good trio of articles by Zvonimir Spajic, on `git` inner workings, how git works under the hood. These tutorials also explain some important git terminology. Among the git details presented here Zvonimir explains that git "sees" a developer's changes in three places: working directory, staging directory and local repository. The staging directory contains a particular version controlled project's git index file. Staged but not committed changes are kept in this index file.


^ Git Terminology

What it means to 'rebase' in context of git . . .

  *  https://git-scm.com/docs/git-rebase


^ Git Branching

An official starting point for git branch use can be found at https://git-scm.com/docs/git-branch. Some articles on the large topic of best branching practices include:

When there are local changes that haven't been committed . . .

  *  https://stackoverflow.com/questions/20568971/git-pull-keeps-telling-me-to-stash-local-changes-before-pulling

Excerpt from above link:

It sounds like your local branch does not have all of the changes on origin.

Firstly, stash your changes

git stash

Then, pull in the changes from origin.

git fetch origin && git rebase origin/(branch name)

Next, add the stash back in to your working directory:

git stash pop


2022

2021 Renaming local and remote branches:

0404


^ Git Merge and Rebase

History re-writing git tools achieved through . . .


^ Git Tags

Command `git show <tag_name>` . . .

A few `git tag` command uses:

    $ git tag
    $ git tag --delete <tag_name>
    $ git tag -a <tag_name> -m "tagging message here" [optional_commit_hash]


^ Git log related

Keywords: git log pickaxe option

A git conventions / best practices article, specific conventions for git commit messages:

Ways to invoke `git log`:

Git's string search parameter or "pickaxe" log option `-S`:

At the command line in a color supporting terminal window, the following `git` invocation produces a useful tree like representation of local and remote branches:

  $ git log --oneline --graph --all


^ Git remotes

Working with multiple git remotes , remote repositories. The following tutorial link to Jigarius leads to a good article. In attempting to set up a local git remote 'definition' with two remote URLs, it became clear that there are issues that break this effort when one remote repo is already created and has pre-existing history. It doesn't matter how short or simple that history is. So this is a good link, but may not be practical to set up multiple remotes to be updated with a single 'push' command when the remotes are not all fully under a given developer's control:

So another question which this prompts, this being the effort to push local work to multiple remotes, is: how does git handle symbolic links? Links at least in the Unix and Linux context?

On git handling of symlinks:

Adding ssh keys to ssh-agent, listing ssh keys, configuring multiple github emails:

How to list git configuration:

  $ git config --list

How to modify remote repository URL:

  $ git remote set-url origin git@github.com:[github_account_username]/[repository_name]

. . . this information thanks to post at https://stackoverflow.com/questions/2432764/how-do-i-change-the-uri-url-for-a-remote-git-repository.


^ Using Git and Subversion Together

Using Git and Subversion on one and the same project looks complicated . . .


^ Git For Windows notes

Looks like with latest (as of 2021-06-16) Git For Windows offers three different ways to configure credentials management. This seems important, here is a link provided by the Git-for-Windows installer:

Locally installed release notes at: file:///C:/Users/<user_name>/AppData/Local/Programs/Git/ReleaseNotes.html


^ References

Git fetch and merge preferrable to git pull . . .

Note: in Firefox 89.0.1 (64-bit) the key binding <CTRL>+j opens a message box showing download progress and history.