Story of a organization Learning Thoughts
-
LT has a product LT-HRMS
-
LT has the
- Management Team
- Sales Team
- Research & Development
- Architecture
- Development
- Testing
- IT Infra Team
-
LT HRMS product is developed, It can be customized. LT HRMS has got a deal from two different customers with some different customizations. There are some other customers in pipeline
-
Now we have three project created
- Customer Apple
- Customer Amazon
- Core Features
-
How should we handle code repository for these situations. To handle parallel tracks in projects we generally create branch
-
Branches in version controls allows to merge changes from one branch to other.
-
How do i create a branch in git
- Git already has default branch master
- Git Branch is a pointer which looks at latest commit.
-
HEAD is a pointer which points to commit id in git. making HEAD to move to different location is considered as checkout
-
Lets create branches for apple, core and amazon
-
Moving around branches
-
If you want create a branch and move the HEAD to that branch (Our sales struck a new deal of tesla, so we need to create)
git checkout master
git checkout -b testla => create a new branch & checkout to that branch
How Git Works?
-
Git is a content tracker
-
Create a new directory and execute git init, a .git folder will be created.
-
Lets add two simple files (Readme.md, .gitignore)
-
Now execute git log
-
Lets understand hashing: Hash algorithms are functions that generate a fixed length result (the hash) from a given input.
-
Git uses SHA-1 Hashing to generate commit ids
-
Git commit id is SHA-1 hash of
- Snapshot of changes in staging area
- Author name
- Author email
- Date time
- Commit message
-
How git maintains versions
- We have create changes in git which appear as
- Lets use plumbing commands
git cat-file -t # This command will tell the type git cat-file -p # This will print the contents of SHA1 hash
- When we print commit id we get
- tree => snapshot of changes done in staging area
- parent => parent commit id
- author =>
- committer =>
- commit message
- Now lets explore the snapshot
- blob stands for file and the hash is hash of contents in the file and tree is folder.
- Now for the current commit the previous commit will be parent and git travels to the initial commit (commit with no parent)
- Now lets create a new commit by copying the same file in 3 different folders
- Now lets look into .git folder, The hashes are encoded in to .git/objects
- Our current working tree depends on pointer HEAD
- Summarize:
- HEAD points to Branch which in turns points to latest commit id
- Git always recommends that HEAD should be pointing to branch not commit, when we force git to do this then it gets into detached head
- Internally Branch is nothing but a moving pointer which points to latest commit
- We have create changes in git which appear as
-
Apple and Amazon have asked for features, There are some common features which
- core team will work
- Rest of features will be worked by customer teams
-
How can i make change in one branch and ensure that change is available to other branches
-
Next Steps:
- Merge
- Cherry pick
- Rebase
- Remotes
- Tags
- Un staging the changes
- modifying commits
- git sub modules & hooks ( After we finish jenkins concepts)
- git branching strategy ( After we finish jenkins concepts)