LNCD

Table of Contents

  • LNCD Home
  • Administration
  • Notebooks
  • Journal Club Presentations
  • Publications
  • Current Projects
  • Completed Projects
  • Current Grants
  • Datasets by Project
  • Brain ROIs and Measures
  • ️Tools And Methods
  • Big Data
  • RA Homepage
  • Recent Changes
  • Maintenance
  • Site Map
  • Random Page
LNCD
Admin » 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
tools:git [2023/10/24 13:02] – [ssh push] willtools:git [2025/09/18 14:23] (current) – [ssh push] will
Line 12: Line 12:
   * https://git-scm.com/doc   * https://git-scm.com/doc
  
-===== Using ===== +===== Track Changes ===== 
-==== Track Changes ====+ 
 +{{:tools:pasted:20250918-141941.png?300}} 
 + 
 +On the command line in terminal/with shell, using git follows the ''add'',''commit'',''push'' pattern.  
 +Need a mnemonic? Think of the ''**A**dorable **C**omputer **P**enguins'' on the [[:tools:mobaxterm]] screensaver.
  
-On the command line in terminal/with shell, using git follows the ''add'',''commit'',''push'' pattern:  
 <code> <code>
 git add $file   # move changes in $file to "staging" git add $file   # move changes in $file to "staging"
Line 21: Line 24:
 git push        # send changes to a server (e.g. github) git push        # send changes to a server (e.g. github)
 </code> </code>
 +
 +<WRAP alert round>
 + **Don't give file paths to ''commit'' or ''push''**.
 +
 +Only the ''git add'' (or friends like ''git mv'' and ''git rm'') command takes file paths as arguments.
 +
 +''git commit'' and ''push'' work on the cumulative ''add''s to create a single snapshot, not individual files.
 +</WRAP>
  
 By default, ''git commit'' will open [[:tools:vim]] to use to write the commit message.  By default, ''git commit'' will open [[:tools:vim]] to use to write the commit message. 
Line 29: Line 40:
   - '':wq'' to write and quit.   - '':wq'' to write and quit.
  
-==== See Changes ====+==== Commit messages ==== 
 + 
 +Each commit in git includes a human-annotated short description in prose. While it's tempting and easy use `"update"` as the entire commit message, future you and colleges will appreciate a more detailed history. There are competing specifications to help guide better commit messages: 
 +  * https://www.conventionalcommits.org/ 
 +  * https://gitmoji.dev/specification 
 + 
 +=== Examples === 
 +Two commit messages in ''conventional commits'' vs ''gitmoji'' 
 +<code> 
 +feat: age model with GAM instead of LM 
 +fix: outlier detection applied to all EEG columns 
 +</code> 
 + 
 +<code> 
 +✨️ model.py: age GAM instead of LM 
 +🐛 plot.R: apply outlier detection ∀ EEG cols 
 +</code> 
 + 
 +===== See Changes ===== 
 A huge benefit of version control is to see the what's changed. This can be done with web, graphical, and command line interfaces. A huge benefit of version control is to see the what's changed. This can be done with web, graphical, and command line interfaces.
  
Line 45: Line 75:
   * push ''/'' to start a search   * push ''/'' to start a search
   * push ''q'' to quit   * push ''q'' to quit
 +
 +===== Github setup =====
 +For ''git push'' to  github, you'll need some way to confirm your credentials. Authentication can happen with **ssh keys** or an **app password**
 +
 ==== Github https push ==== ==== Github https push ====
 To push to ''https'' (vs ssh like ''git@'') repos, you'll need to use a personal authentication token when prompted for a password. See [[https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens|github's documentation]] To push to ''https'' (vs ssh like ''git@'') repos, you'll need to use a personal authentication token when prompted for a password. See [[https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens|github's documentation]]
Line 52: Line 86:
  
  
-Contents of ''~/.ssh/id_rsa.pub'' into ''top right user icon''->''settings''->''ssh and GPG keys'' -> ''new ssh key'' +Contents of ''~/.ssh/id_rsa.pub'' should be pasted into ''new ssh key'' modal on https://github.com/settings/keys ((''top right user icon''->''settings''->''ssh and GPG keys'' -> ''new ssh key'')) 
-{{:tools:pasted:20231024-130110.png}}+{{:tools:pasted:20231024-130110.png?300}}
  
  
 If ''~/.ssh/id_rsa.pub'' doesn't exist, ''ssh-keygen'' can make it (use empty password for convience. hit enter at password prompt to leave blank). See more [[https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent|documentaiton on github]] If ''~/.ssh/id_rsa.pub'' doesn't exist, ''ssh-keygen'' can make it (use empty password for convience. hit enter at password prompt to leave blank). See more [[https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent|documentaiton on github]]
 +
 +===== Advanced =====
 +  * [[https://git-scm.com/docs/git-worktree|working trees]] for working on more than one branch at a time
 +  * ''git add $file; git commit --amend --noedit; git push --force''
 +  * rebase, esp with [[https://magit.vc/manual/magit/Rebasing.html|emacs+magit's rebase UI]] 
 +  * [[https://jvns.ca/blog/2023/11/01/confusing-git-terminology/|confusing terms]]
 +  * [[https://jvns.ca/blog/2024/02/16/popular-git-config-options/|popular git config options]]
 +  
 +