Difference between revisions of "Git"
Jump to navigation
Jump to search
Tags: Mobile web edit, Mobile edit |
(→Tips and Tricks: * <code>git update-git-for-windows</code>) Tags: Mobile web edit, Mobile edit |
||
Line 65: | Line 65: | ||
== 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> | ||
+ | |||
+ | |||
+ | == Related terms == | ||
+ | * <code>git update-git-for-windows</code> | ||
== Activities == | == Activities == |
Revision as of 09:26, 1 June 2020
Git
is a distributed revision control software.
Activities
Git Installation
- Download Git from https://git-scm.com/downloads.
- Install Git. (MacOS:
brew install git
)
Copy an existing remote repository
- 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
- 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
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:
git add .
[1] orgit add some_modified_file.txt
orgit add -A
- Commit changes.
- Commit changes into the local repository using the command:
git commit -m "<some message>"
- Commit changes into the local repository using the command:
- Connect to a remote repository.
- Connect to a remote repository using the command:
git remote add <name> <url>
[2]
- Connect to a remote repository using the command:
- Push changes to a remote repository.
- Push changes from your local repository to a remote repository using the command:
git push
[3] orgit push origin master
orgit push -h origin master
- Push changes from your local repository to a remote repository using the command:
Retrieve Remote Changes
- 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)[4]ls | parallel git -C {} fetch
-C <PATH>
run as if git was started in <path> instead of the current working directory.
Repository information
git remote -v
orgit remote show origin
orgit config --get remote.origin.url
[5]
git log
git log, git shortlog, git log --all
Git show
git show 3c88ad72430
Tags / Releases
- Show all tags in git log:[6]
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"
[7]. 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
git log --decorate=full --simplify-by-decoration
- Print lines matching a pattern:
git grep TEXT_TO_SEARCH
git merge
[8]
Tips and Tricks
- To avoid using
--pager
in allgit log
commands, add the following line to your~/.bash_profile
file:[9]export GIT_PAGER=cat
Related terms
git update-git-for-windows
Activities
- 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
See also
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- Software development: SDLC, SCM,
git
, GitHub, GitLab, TeamCity, Jenkins, CircleCI, Rational ClearCase, AWS CodeCommit, VCS,/sys/dev/
, DDD, EDA - gitrob, TruffleHog, gitleaks
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
- ↑ http://man7.org/linux/man-pages/man1/git-add.1.html
- ↑ http://man7.org/linux/man-pages/man1/git-remote.1.html
- ↑ https://git-scm.com/docs/git-push
- ↑ 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: