Editing Git

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
<code>[[wikipedia:git (software)|git]]</code> ([[2005]]) is a distributed [[revision control software]].
+
<code>[[wikipedia:git (software)|Git]]</code> ([[2005]]) is a distributed revision control software.
 +
 
 +
 
  
 
* [[git init]]
 
* [[git init]]
Line 17: Line 19:
 
=== Git Installation ===
 
=== Git Installation ===
 
# Download Git from https://git-scm.com/downloads.
 
# Download Git from https://git-scm.com/downloads.
# Install Git. (MacOS: <code>[[brew install git]]</code>)
+
# Install Git. (MacOS: <code>brew install git</code>)
# apt install git or apt install [[git-all]]
 
  
 
=== Copy an existing remote repository ===
 
=== Copy an existing remote repository ===
Line 32: Line 33:
 
#* Initialize the folder using the command:<br><code>[[git init]]</code>
 
#* Initialize the folder using the command:<br><code>[[git init]]</code>
  
=== [[Make Local Changes and Update remote Repositories]] ===
+
=== Make Local Changes and Update remote Repositories ===
 +
Add local changes.
 +
# Stage files.
 +
#* Add files to the folder or modify existing files.
 +
#* Add new and modified files to the git staging area using the command:<br><code>git add .</code><ref>http://man7.org/linux/man-pages/man1/git-add.1.html</ref> or <code>git add some_modified_file.txt</code> or <code>git add -A</code>
 +
# Commit changes.
 +
#* Commit changes into the local repository using the command:<br><code>[[git commit]] -m "&lt;some message&gt;"</code>
 +
# Connect to a remote repository.
 +
#* Connect to a remote repository using the command:<br><code>git remote add &lt;name&gt; &lt;url&gt;</code><ref>http://man7.org/linux/man-pages/man1/git-remote.1.html</ref>
 +
# Push changes to a remote repository.
 +
#* Push changes from your local repository to a remote repository using the command:<br><code>git push</code><ref>https://git-scm.com/docs/git-push</ref> or <code>git push origin master</code> or <code>git push -h origin master</code>
  
 
=== Retrieve Remote Changes ===
 
=== Retrieve Remote Changes ===
Line 38: Line 49:
 
** Pull/get changes from a remote repository to your local repository using the command:
 
** Pull/get changes from a remote repository to your local repository using the command:
 
:::<code>[[git pull]]</code> or <code>git pull &lt;name&gt; &lt;branch&gt;</code>
 
:::<code>[[git pull]]</code> or <code>git pull &lt;name&gt; &lt;branch&gt;</code>
:::<code>[[git pull -v]]</code> (for more [[verbose]] output)
+
:::<code>git pull -v</code> (for more verbose output)
 
:::<code>[[git fetch]]</code>
 
:::<code>[[git fetch]]</code>
:::<code>[[gfind]] $1 -name "[[.git]]" | gsed -r 's|/[^/]+$||' | parallel "echo {}; git -C {} pull" </code> (git pull all your repos in parallel, MacOS version)
+
:::<code>[[gfind]] $1 -name ".git" | gsed -r 's|/[^/]+$||' | parallel "echo {}; git -C {} pull" </code> (git pull all your repos in parallel, MacOS version)
 
* Pull subdirectories:
 
* Pull subdirectories:
 
::<code>ls | parallel git -C {} pull</code> (assuming all sub-dirs are git repositories)<ref>https://stackoverflow.com/a/33557279</ref>
 
::<code>ls | parallel git -C {} pull</code> (assuming all sub-dirs are git repositories)<ref>https://stackoverflow.com/a/33557279</ref>
Line 47: Line 58:
  
 
=== Repository information ===
 
=== Repository information ===
* <code>[[git remote]] -v</code> or <code>git remote show origin</code> or <code>[[git config]] --get remote.origin.url</code><ref>https://stackoverflow.com/questions/4089430/how-can-i-determine-the-url-that-a-local-git-repository-was-originally-cloned-fr</ref>
+
* <code>git remote -v</code> or <code>git remote show origin</code> or <code>[[git config]] --get remote.origin.url</code><ref>https://stackoverflow.com/questions/4089430/how-can-i-determine-the-url-that-a-local-git-repository-was-originally-cloned-fr</ref>
  
 
=== [[git log]] ===
 
=== [[git log]] ===
 
{{git log}}
 
{{git log}}
  
=== [[git show]] ===
+
=== Git show ===
 
* <code>[[git show]] 3c88ad72430</code>
 
* <code>[[git show]] 3c88ad72430</code>
  
Line 63: Line 74:
 
* <code>git log --decorate=full --simplify-by-decoration</code>
 
* <code>git log --decorate=full --simplify-by-decoration</code>
 
* Print lines matching a pattern:<code>git grep TEXT_TO_SEARCH</code>
 
* Print lines matching a pattern:<code>git grep TEXT_TO_SEARCH</code>
* <code>[[git merge]]</code><ref>https://dev.to/neshaz/how-to-use-git-merge-the-correctway-25pd</ref>
+
* <code>git merge</code><ref>https://dev.to/neshaz/how-to-use-git-merge-the-correctway-25pd</ref>
* [[Move existing, uncommitted work to a new branch in git]]
 
  
 
== Tips and Tricks ==
 
== Tips and Tricks ==
 
* To avoid using <code>--pager</code> in all <code>git log</code> commands, add the following line to your <code>~/.bash_profile</code> file:<ref>https://stackoverflow.com/a/7737071</ref><br><code>export GIT_PAGER=cat</code>
 
* To avoid using <code>--pager</code> in all <code>git log</code> commands, add the following line to your <code>~/.bash_profile</code> file:<ref>https://stackoverflow.com/a/7737071</ref><br><code>export GIT_PAGER=cat</code>
  
== Security ==
 
* [[CVE-2022-24765]] windows and multi-user environments
 
* [[gitrob]], [[TruffleHog]], [[gitleaks]]
 
  
 
== Related terms ==
 
== Related terms ==
 
* <code>git update-git-for-windows</code>
 
* <code>git update-git-for-windows</code>
* [[Git Large File Storage (LFS)]]: <code>[[git lfs install]]</code>
+
* [[Git Large File Storage (LFS)]]
* <code>[[git-crypt]]</code>
 
* <code>[[.git/config]]</code>
 
* [[GitFlow]]
 
* <code>[[git stash]]</code>
 
* [[GitBook]]
 
* <code>[[diffuse -m]]</code>
 
 
 
== Related software ==
 
 
* [[GitHub]] ([[2008]])
 
* [[GitHub]] ([[2008]])
 
* [[GitLab]] ([[2011]])
 
* [[GitLab]] ([[2011]])
* [[Bitbucket]] (2008)
 
  
 
== Activities ==
 
== Activities ==
 
# [[Clone some git public repositories]]
 
# [[Clone some git public repositories]]
# Learn what is a merge or [[pull request]]: https://stackoverflow.com/questions/23076923/what-is-a-merge-request
+
# Learn what is a merge or pull request: https://stackoverflow.com/questions/23076923/what-is-a-merge-request
# Create your first website in [[Website Hosting]] using <code>git</code>
+
# Create your first website in [[Website Hosting]] using git
 
# Read StackOverflow questions about Git: https://stackoverflow.com/questions/tagged/git?tab=Votes
 
# Read StackOverflow questions about Git: https://stackoverflow.com/questions/tagged/git?tab=Votes
# [[Make Local Changes and Update remote Repositories]]
 
# [[Create Git branch with current changes]]
 
  
 
== See also ==
 
== See also ==
 
* {{git}}
 
* {{git}}
 
* {{git software}}
 
* {{git software}}
* {{VCS}}
 
 
* {{dev}}
 
* {{dev}}
 
+
* [[gitrob]], [[TruffleHog]], [[gitleaks]]
  
  
Line 107: Line 102:
  
 
[[Category: Computer programming]]
 
[[Category: Computer programming]]
[[Category:Concurrent Versions System]]
 

Please note that all contributions to wikieduonline may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Wikieduonline:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Advertising: