Git
INFO
Git is free and open source software for distributed version control: tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows. Git was originally authored by Linus Torvalds in 2005 for development of the Linux kernel, with other kernel developers contributing to its initial development. Since 2005, Junio Hamano has been the core maintainer. As with most other distributed version control systems, and unlike most client–server systems, every Git directory on every computer is a full-fledged repository with complete history and full version-tracking abilities, independent of network access or a central server. Git is free and open-source software distributed under the GPL-2.0-only license
Developer : Linus Torvalds
USE
Configure Git
➜ git config --global user.name "kooshakoosha"
➜ git config --global user.email "kooshakooshadv@gmail.com"
Initialize Git
➜ git init
Status
➜ git status
➜ git status --short
Stage Mode
➜ git add <filename>
➜ git add -A
Commit
The commit command performs a commit, and the -m "message" adds a message.
➜ git commit -m <message>
example:
➜ git commit -m "This is First commit"
LOG
➜ git log
Diff
➜ git diff HEAD
➜ git diff staged
Reset
Note: With Reset Command You can take it from stage step
➜ git reset <filename>
Checkout
if You want to reset File changing and take that to Previous commit use this command
➜ git checkout -- <filename>
➜ git checkout commit_id .
➜ git checkout <branchname>
➜ git checkout v1.8
Note : this is'nt branch and You cant commit to it
Branch
In Git, a branch is a new/separate version of the main repository.
show Branch :
➜ git branch
Create New Branch :
➜ git branch <branchname>
Delete Branch :
➜ git branch -d <branchname>
Remove
➜ git rm <filename>
Merge
➜ git merge <branchname>
Push
➜ git push
➜ git push origin master
Pull
➜ git pull
Get Every Informations from Origin ro Master:
➜ git pull origin master
Clone
A clone is a full copy of a repository, including all logging and versions of files.
➜ git clone <address>
Remote
➜ git remote add origin <address>
➜ git remote # show remote address
Show remote address and verbose :
➜ git remote -v
Tag
Tags are references showing particular points in a Git history. The main function of tagging is to capture a point in a Git history that marks version release. Tags don't change. After a tag is created, it has no history of commits
➜ git show <commit name>
commit name like this 004256975sd58a5d8dsd
➜ git tag
# this allow you cab tag to Your ap
➜ git tag -a v2.0 -m "comments"
➜ git tag -l "v*"
➜ git show v1.0
➜ git push origin v1.8
Ignore
When sharing your code with others, there are often files or parts of your project, you do not want to share.
log files
temporary files
hidden files
personal files
etc.
GitHub Fork
Add to Someone Else's Repository
At the heart of Git is collaboration. However, Git does not allow you to add code to someone else's repository without access rights.
A fork is a copy of a repository. This is useful when you want to contribute to someone else's project or start your own project based on theirs.
gpg
➜ gpg --list-leys
➜ gpg --gen-key
➜ git config --global user.name
➜ git config --global user.signingkey
➜ gpg --list-secret-keys --keyid-format LONG
➜ gpg config --global user.signingkey 0325419413581 # this is Abount signing key and user private key
Debug with Git
➜ git blame <Filename> -L8 # Show Results of who write or coomit 8th line of file
➜ git blame <filename> -L8,10
➜ git blame <filename>
Last updated