Difference between revisions of "Git"
Jump to navigation
Jump to search
Tags: Mobile web edit, Mobile edit |
|||
(21 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | <code>[[wikipedia:git (software)| | + | <code>[[wikipedia:git (software)|git]]</code> ([[2005]]) is a distributed [[revision control software]]. |
+ | |||
+ | * [[git init]] | ||
+ | * [[git bisect]] | ||
+ | * [[git clone]] | ||
+ | * [[git config]] | ||
+ | * [[git log]] | ||
+ | * [[git pull]] | ||
+ | * [[git push]] | ||
+ | * [[git fetch]] | ||
+ | * [[git remote]] | ||
+ | * [[git show]] | ||
+ | * [[git checkout]] | ||
+ | * [[git switch]] | ||
== Activities == | == Activities == | ||
=== 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 26: | Line 40: | ||
:::<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 38: | Line 52: | ||
{{git log}} | {{git log}} | ||
− | === | + | === [[git show]] === |
* <code>[[git show]] 3c88ad72430</code> | * <code>[[git show]] 3c88ad72430</code> | ||
Line 49: | Line 63: | ||
* <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 == | ||
Line 63: | Line 81: | ||
* <code>[[git stash]]</code> | * <code>[[git stash]]</code> | ||
* [[GitBook]] | * [[GitBook]] | ||
+ | * <code>[[diffuse -m]]</code> | ||
== Related software == | == Related software == | ||
Line 75: | Line 94: | ||
# 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]] | # [[Make Local Changes and Update remote Repositories]] | ||
+ | # [[Create Git branch with current changes]] | ||
== See also == | == See also == | ||
Line 81: | Line 101: | ||
* {{VCS}} | * {{VCS}} | ||
* {{dev}} | * {{dev}} | ||
− | + | ||
Latest revision as of 10:53, 20 April 2024
git
(2005) is a distributed revision control software.
- git init
- git bisect
- git clone
- git config
- git log
- git pull
- git push
- git fetch
- git remote
- git show
- git checkout
- git switch
Contents
Activities[edit]
Git Installation[edit]
- Download Git from https://git-scm.com/downloads.
- Install Git. (MacOS:
brew install git
) - apt install git or apt install git-all
Copy an existing remote repository[edit]
- Clone a remote repository.
- Select a local folder to copy the repository into, or create a new folder if you prefer. The repository will be copied as a subdirectory of the selected folder.
- At a command or terminal prompt, navigate to the selected folder.
- Clone the repository using the command:
git clone URL_TO_REPO
. See also:git pull
andgit fetch
Create a local repository[edit]
- Initialize a folder for Git.
- Select a local folder to add to Git, or create a new folder if you are starting a new project.
- At a command or terminal prompt, navigate to the selected folder.
- Initialize the folder using the command:
git init
Make Local Changes and Update remote Repositories[edit]
Retrieve Remote Changes[edit]
- Pull/get changes from a remote repository to have latest version of the code
- Pull/get changes from a remote repository to your local repository using the command:
- Pull subdirectories:
ls | parallel git -C {} pull
(assuming all sub-dirs are git repositories)[1]ls | parallel git -C {} fetch
-C <PATH>
run as if git was started in <path> instead of the current working directory.
Repository information[edit]
git remote -v
orgit remote show origin
orgit config --get remote.origin.url
[2]
git log[edit]
git log, git shortlog, git log --all
git show[edit]
git show 3c88ad72430
Tags / Releases[edit]
- Show all tags in git log:[3]
git log --no-walk --tags --pretty="%h %d %s" --decorate=full
git tag
(show releases)- List tags with dates:
git log --tags --simplify-by-decoration --pretty="format:%ci %d"
[4]. Just can also addtaglog = log --tags --simplify-by-decoration --pretty='format:%ci %d'
(note the single-, NOT double-quotes) in the [alias] section of your gitconfig file.
Miscelaneous[edit]
git log --decorate=full --simplify-by-decoration
- Print lines matching a pattern:
git grep TEXT_TO_SEARCH
git merge
[5]- Move existing, uncommitted work to a new branch in git
Tips and Tricks[edit]
- To avoid using
--pager
in allgit log
commands, add the following line to your~/.bash_profile
file:[6]export GIT_PAGER=cat
Security[edit]
- CVE-2022-24765 windows and multi-user environments
- gitrob, TruffleHog, gitleaks
Related terms[edit]
git update-git-for-windows
- Git Large File Storage (LFS):
git lfs install
git-crypt
.git/config
- GitFlow
git stash
- GitBook
diffuse -m
Related software[edit]
Activities[edit]
- Clone some git public repositories
- 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
git
- 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[edit]
git
: [config | init | status ]
,git add
,git rm
,git commit
,git push, git pull
,.gitconfig
,.gitignore
,git
(clone
,fetch
,pull
),git tag
,git log
,git blame
, Merge Request, LFS,git branch
,git apply
,git rebase
,git diff
,git diff-tree
,git config --global
,remote | submodule | request-pull
,GIT_TRACE, GIT_CURL_VERBOSE
,clean
,main
,git show-ref
,git reset
,git prune
,git ls-remote origin
,git checkout
,git switch
,pathspec
,git credential-osxkeychain
,git version
,pre-commit
,git --help
, GitBook,refs/
git
, GitHub, GitLab, Gerrit, TeamCity, Jenkins, CircleCI, Bitbucket, AWS Codecommit- VCS: GitHub, GitLab, AWS CodeCommit, Bitbucket, Assembla, GitKraken, Azure DevOps
- Software development: SDLC, SCM,
git
, GitHub, GitLab, TeamCity, Jenkins, CircleCI, Rational ClearCase, AWS CodeCommit, VCS,/sys/dev/
, DDD, EDA
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Source: wikiversity
- ↑ https://stackoverflow.com/a/33557279
- ↑ https://stackoverflow.com/questions/4089430/how-can-i-determine-the-url-that-a-local-git-repository-was-originally-cloned-fr
- ↑ https://stackoverflow.com/questions/4211604/show-all-tags-in-git-log
- ↑ https://stackoverflow.com/a/13208822
- ↑ https://dev.to/neshaz/how-to-use-git-merge-the-correctway-25pd
- ↑ https://stackoverflow.com/a/7737071
Advertising: