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
Last revision Both sides next revision
linux_wiki:git [2019/07/13 19:50]
billdozor [Git]
linux_wiki:git [2020/01/10 18:29]
billdozor [Extra Characters in git diff]
Line 49: Line 49:
 ====== Initial Git Config Setup ====== ====== Initial Git Config Setup ======
  
-Setup your name for commits:+Setup your user name for commits:
 <code bash> <code bash>
 git config --global user.name "USERNAME" git config --global user.name "USERNAME"
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 'ESC[xxx' characters in git diff<code bash>git config --global core.pager "less -R"</code>
 +\\
 +
 +* Fix '^M' characters<code bash>git config --global core.pager "tr -d '\r' | less -REX"</code>
  
 ---- ----
  
  • linux_wiki/git.txt
  • Last modified: 2020/01/10 18:29
  • by billdozor