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 19:51]
billdozor [Initial Git Config Setup]
linux_wiki:git [2020/01/10 18:29] (current)
billdozor [Extra Characters in git diff]
Line 79: Line 79:
 </code> </code>
  
----- +\\ 
- +Disable https verify for self signed certs on a single cloned repo<code bash>git config http.sslVerify false</code>
-====== Clone Repos ====== +
- +
-Download an existing project via URL<code bash>git clone URL</code>+
  
 \\ \\
-Download an existing project via HTTPS URL and do not verify ssl cert for self signed<code bash>git -c http.sslVerify=false clone https://URL</code>+Alternatively, configure git to trust self signed certs: https://stackoverflow.com/questions/9072376/configure-git-to-accept-a-particular-self-signed-server-certificate-for-a-partic
  
 ---- ----
  
-====== Configure Repos ======+====== Create/Clone Repos ======
  
-Disable https verify for self signed certs on single cloned repo<code bash>git config http.sslVerify false</code>+Create a new local project (to be pushed up to a repo later)<code bash>git init <project-name></code>
  
 \\ \\
-Alternatively, configure git to trust self signed certs: https://stackoverflow.com/questions/9072376/configure-git-to-accept-a-particular-self-signed-server-certificate-for-a-partic+Download an existing project via URL<code bash>git clone URL</code> 
 + 
 +\\ 
 +Download an existing project via HTTPS URL and do not verify ssl cert for self signed<code bash>git -c http.sslVerify=false clone https://URL</code>
  
 ---- ----
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.1563061900.txt.gz
  • Last modified: 2019/07/13 19:51
  • by billdozor