Lore

If it's worth remembering, it's worth writing down, if I find the time, and remember...

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 [2018/05/10 14:37] thekojukinatorgit [2019/05/08 16:08] (current) – [PowerShell Visual Studio Code Template] thekojukinator
Line 7: Line 7:
   * https://www.atlassian.com/git/tutorials - More great tutorials here.   * https://www.atlassian.com/git/tutorials - More great tutorials here.
   * https://help.github.com - GitHub documentation.   * https://help.github.com - GitHub documentation.
 +  * https://guides.github.com/features/mastering-markdown - Markdown reference.
  
 I was using ''git version 2.16.2.windows.1'' in the //Bash// shell while documenting and testing these commands. I was using ''git version 2.16.2.windows.1'' in the //Bash// shell while documenting and testing these commands.
Line 34: Line 35:
 </code> </code>
  
 +A complementary setting in //Visual Studio Code// when developing on Windows is to enforce CRLF.
 +
 +<code css settings.json>
 +{
 +    // this assumes Windows dev environment with Git config option "core.autocrlf=true"
 +    "files.eol": "\r\n"
 +}
 +</code>
 ==== Pretty Log Alias ==== ==== Pretty Log Alias ====
  
Line 42: Line 51:
 <code bash> <code bash>
 git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
 +# or without pagination
 +git --no-pager log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
 </code> </code>
  
Line 48: Line 59:
 <code bash> <code bash>
 git config --global alias.hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short" git config --global alias.hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"
 +# unfortunately these won't work...
 +git config --global alias.hist "--no-pager log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"
 +git config --global alias.hist "!git --no-pager log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"
 +# but, this will disable pagination for all calls to 'log'
 +git config --global pager.log false
 +
 +# I've recently discovered some prettier log outputs, so my .gitconfig aliases are like so...
 +hist = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
 +hist1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'
 +hist2 = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
 +# first two are courtesy of https://stackoverflow.com/a/9074343
 </code> </code>
  
Line 278: Line 300:
 git remote set-branches --add origin dev1 git remote set-branches --add origin dev1
 </code> </code>
 +
 +When a tag is removed from the local **repo** it will not be removed from the remote **repo** via standard ''git push'' or even ''git push --all'', but there is a way to do it.
 +
 +<code bash>
 +# delete <tag> from <remoterepo>
 +git push <remoterepo> :<tag>
 +# ex:
 +git push origin :v1.0
 +</code>
 +
 +Alternatively, if new tags were created but there are no new commits, it's possible to push the tags to the remote **repo** via ''git push --tags''.
  
 ===== Stage, Confirm, Commit, and Tag ===== ===== Stage, Confirm, Commit, and Tag =====
Line 525: Line 558:
 !*/ !*/
  
-# allow .gitignore at top level +# allow .git* at top level 
-!.gitignore+!.git*
  
-whitelist these file types everywhere +allow .md at top level 
-!**/*.ps1 +!*.md 
-!**/*.psm1 + 
-!**/*.psd1 +# whitelist VSCode settings at the top level 
-!**/*.xml+!/.vscode/settings.json 
 + 
 +# whitelist contents of these folders at the top level 
 +!/ProjectFolderContainingAllTheGoodies/** 
 + 
 +# regardless of above, ignore these folders and files everywhere 
 +**/_logs
 +**/_testing*
  
-# regardless of above, ignore '.vscode' folder everywhere 
-**\.vscode/ 
 </code> </code>
  
Line 580: Line 618:
  
 # End of https://www.gitignore.io/api/windows,powershell,visualstudiocode # End of https://www.gitignore.io/api/windows,powershell,visualstudiocode
-</code> 
- 
-===== GitHub ===== 
- 
-==== Pushing via SSH ==== 
- 
-After following [[https://help.github.com/articles/connecting-to-github-with-ssh|this guide]] to create an SSH key, add it to the ''ssh-agent'', and add it to the GitHub account, the remote repo URL must be updated on the local repo. 
- 
-<code bash> 
-git remote set-url origin git+ssh://git@github.com/<username>/<reponame>.git 
-# ex: 
-git remote set-url origin git+ssh://git@github.com/bob/CoolProject.git 
 </code> </code>
  
 {{tag>computing git}} {{tag>computing git}}
git.1525977421.txt.gz · Last modified: 2018/05/10 14:37 by thekojukinator