linux_wiki:git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux_wiki:git [2019/07/13 20:01]
billdozor
linux_wiki:git [2020/01/10 18:29] (current)
billdozor [Extra Characters in git diff]
Line 134: Line 134:
       * View recent commits with diff details<code bash>git log -p</code>       * View recent commits with diff details<code bash>git log -p</code>
       * Retrieve the commit SHA hash from the above and revert that push<code bash>git revert <SHA></code>       * Retrieve the commit SHA hash from the above and revert that push<code bash>git revert <SHA></code>
 +
 +----
 +
 +====== Exclude Files from Tracking ======
 +
 +A plain text file called '.gitignore' in the project root excludes files and directories from tracking by git.
 +
 +Full documentation here: https://git-scm.com/docs/gitignore
 +
 +\\
 +Example .gitignore<code bash># Git ignore file - comments are allowed
 +__pycache__/
 +*.log
 +tmp/</code>
 +  * Do not track any files that
 +    * Are inside a __pycache__ directory
 +    * End in .log
 +    * Are inside a tmp directory
 +
 +\\
 +List all ignored files in the current project<code bash>git ls-files --other --ignored --exclude-standard</code>
  
 ---- ----
Line 279: Line 300:
 ===== Deleting Branches ===== ===== Deleting Branches =====
  
 +Delete a remote branch<code bash>git push origin --delete <branch-name></code>
 +
 +\\
 Delete a local branch<code bash>git branch --delete <branch-name></code> Delete a local branch<code bash>git branch --delete <branch-name></code>
 +
 +\\
 +Prune remote list if remote branches were deleted by someone else<code bash>git remote prune origin</code>
  
 ---- ----
Line 309: Line 336:
  
   * Push local changes to your fork on github<code bash>git push origin master</code>   * Push local changes to your fork on github<code bash>git push origin master</code>
 +
 +----
 +
 +====== Troubleshooting ======
 +
 +Fixing different git issues.
 +
 +===== Extra Characters in git diff =====
 +
 +* Fix/remove 'ESC[xxx' characters in git diff<code bash>git config --global core.pager "less -R"</code>
 +\\
 +
 +* Fix/remove '^M' characters in git diff<code bash>git config --global core.pager "tr -d '\r' | less -REX"</code>
  
 ---- ----
  
  • linux_wiki/git.1563062512.txt.gz
  • Last modified: 2019/07/13 20:01
  • by billdozor