Git: Source versioning System
GitHub, Gitlab & Bitbucket are service providers for version Control
GitHub: Public and Open Source
GitLab: Private & to use for Organization
Git Commands:
Version: $git --version
Set User Name: $ git config --global user.name = "Lavakush"
Get User Name: $ git config --global user.name
Get all Global Config list: $ git config --global --list
Check out Master: $ git checkout master
Pull latest changes: $ git pull origin master -u
Create Branch: $ git checkout -b "branch name"
Check the changes: $ git status
Add all files: $git add *
Store the changes : $ git commit -m "comment"
push the changes to remote repo: $ git push -u origin master
How GIT Works
- Git is repository is a key-value object store all objects are indexed by SHA-1 hash value.
- All commits & commented files different type of objects living in repository.
- A git is large Hash table with no provision made for hash collection.
- Git specifically works by taking shortstops of files
LIST OF COMMANDS:-
1. Help
$ git help
2. Get help from help of config
$ git help config
3. Configure name
$ git config –global user.name= “Lavakush”
4. Configure email
$ git config –global user.email=Lokesh.nbp@gmail.com
5. Initiate git
$ git init
6. Add a file
$ git add filename.txt
7. To commit
$git commit -m “Comment”
8. To check the history of commits
$ git log
9. Different ways to add the add
command and files
$ git add –all
$ git add “*.txt”
$ git add folder /
$ git add folder/*.txt
10. Check changes from last commit
$ git diff
11. To undo staging of the file add
in staging
$ git reset head licence
12. Undo last commit & bring file
to staging
$ git reset -soft HEAD ^
13. Undo last commit & remove
from staging
$ git rest -hard HEAD ^
14. To remove last 2 commits
$ git reset -hard HEAD ^^
15. REMOTE ADDRESS
$ git remote add origin “URL”
$ git push -u origin master
$ git clone URL
BRANCH
16. Create Branch
$ git branch testing
17. list all the branches
$ git branch
18. Check out a branch
$ git checkout testing
19. To merge testing branch with
master
$git merge testing
20. Delete branch
$ git branch -d testing
21. PULL VS FETCH
Git pull = Git Fetch + Git Merge
22. What is git Stash
If we are in middle of some task and need to jump to another task we use stash
23. STAGING AREA OR INDEX
Is before competing the commits,
it can formatted & reviewed in intermediate area known as Staging Area or
Index
24. Git ARCHITECHTURE