Muhammad Shakhawat Hossain
java-project
java-project-updated
java-project-latest
java-project-final
java-project-final-1
java-project-final-2
java-project-final-final.zip
April 2005
3 core requirement by
Linus Torvalds
-> git version
-> git version 2.26.2
-> git config --global user.name "Safat Hossain"
-> git config --global user.email "safat@gmail.com"
-> cat ~/.gitconfig
[user] name = Safat Hossain email = safat@gmail.com
-> cat ~/.gitconfig
-> git config --list
-> cat ~/.gitconfig
git-101
- Logically keep log of the changes
- Versioning of the changes
- Undo changes
- Share changes with collaborators
- Get code review
- At any point of time, allow to see the change log of the project
- Secure place to host and share source code
git-101
-> git status
-> git init
Initialized empty Git repository in /Users/safat/git-101/.git/
fatal: not a git repository (or any of the parent directories): .git
total 0
drwxr-xr-x 7 safat 120070500 224 May 2 20:08 .
drwxr-xr-x+ 119 safat 120070500 3808 May 2 20:08 ..
drwxr-xr-x 9 safat 120070500 288 May 2 20:08 .git
-> ls -al
git-101
-> git status
->
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
frontend.py
backend.py
nothing added to commit but untracked files present (use "git add" to track)
-> DO yourself: Create two files and write few lines of code/text
-> git status
-> git status
git-101
-> git status
-> git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: frontend.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
backend.py
-> git add frontend.py
git-101
-> git status
-> git status
Untracked files: (use "git add <file>..." to include in what will be committed) backend.py nothing added to commit but untracked files present (use "git add" to track)
-> git commit -m "Front-end work initial commit"
-> git log
Untracked files: (use "git add <file>..." to include in what will be committed) backend.py nothing added to commit but untracked files present (use "git add" to track)
Untracked files: (use "git add <file>..." to include in what will be committed) backend.py nothing added to commit but untracked files present (use "git add" to track)
commit 200b9d5766a36102b1fa51397d41e29d880eba44 (HEAD -> master) Author: Safat Hossain <safat@gmail.com> Date: Sat May 2 20:51:59 2020 +0800 f Front-end work initial commitend-end work
git-101
-> Commit backend.py
-> git log
commit 200b9d5766a36102b1fa51397d41e29d880eba44 (HEAD -> master)
Author: Safat Hossain <safat@gmail.com>
Front-end work initial commit
commit752a7082490cec3b19790e861b5027239db9d6c4(HEAD -> master) Author: Safat Hossain <safat@gmail.com>
Back-end work initial commit
ront-end work
git-101
-> Make some changes in front-end module
-> git diff
diff --git a/frontend.py b/frontend.py index e69de29..14b192e 100644 --- a/frontend.py +++ b/frontend.py @@ -0,0 +1 @@ +print("some enhancements in the front-end")
Add to staging area -> git add
Commit changes -> git commit -m "Front-end enhancements"
Check git log -> git log
-> git add
-> git status
-> git commit
-> git log
-> git diff
-> git add
-> git status
-> git commit
-> git log
-> git diff
tracking
staging area
untracked -> tracked -> staged -> committed
git-101
-> git remote -v
-> git remote add origin git@github.com:safat/git-101.git
-> git push origin HEAD
-> git branch demo origin/master
-> git branch
master
demo
-> git checkout demo
1. make some changes
2. add to stage
3. commit changes
4. push to remote [git push origin head]
-> git clone git@github.com:safat/git-101.git
master
commit 1 -> commit 2 -> commit 3
demo \
---------------------------------- \ commit 4
-> git pull origin master
-> git log
master
commit 1 -> commit 2 -> commit 3 ----------- > merge commit 4
demo \ /
---------------------------------- \ commit 4
-> git add
-> git status
-> git commit
-> git log
-> git diff
Create a remote repository
Push local repository to remote
Clone remote repository
Create branch, raise a Pull request
Merge a Pull request
Pull back changes to local repository
-> git commit --amend
1. make your changes
2. add to the staging area
3. use amend to amend the changes to the previous commit
4. push the changes to remote
5. if you have pushed the previous commit already to remote, you have to force push now
Correct your previous commit
Steps
-> git reset --soft commit_hash
-> git reset --hard commit_hash
Remove a commit
-> git rebase -i HEAD~n
pick 5d4ac8b Back-end work initial commit edit a2b4f3d Some front-end enhancements pick b647a7b Config changes for Demo
1. issue the rebase command, now you will be in a temporary detached HEAD
2. make the changes and add to the stage, -> git add file_namne
3. amend the changes, -> git commit --amend
4. git rebase --continue
Steps
-> git rebase -i HEAD~n
pick 5d4ac8b Back-end work initial commit s a2b4f3d Minor refactorings in the Controllers s b647a7b Fix error in HelloController
-> git log
-> git cherry-pick commit_hash
-> git log
-> git cherry-pick commit_hash
-> git log
1. What is inside the .git directory?
2. What is git object and packed-refs
3. What does the commit hash means, can there be hash conflicts?
4. If I create a branch, is it expensive? Does git copy over all the changes? Does it create diff?
5. What is git gc?
6. What is merge conflict, how to resolve it?
7. How to use reflog?
8. How to add more than one remote?
UI Tools