DevOps Classroom Series – 13/Dec/2019

Git History

  • Every Change moved from staging Area to Local Repo is called as COMMIT.
  • Every Commit has an ID
  • using GIT you can move to any commit in history.
  • Lets Define HEAD. HEAD is pointer which points to commit id working tree is looking at.
  • Lets try to move the HEAD to Third commit. For that you need commit id. Commit id which can be used are long and short
git log
git log --oneline

  • Now Lets move the HEAD to Third Commit
git checkout 7907137
  • Now to move the HEAD back to latest commit
git checkout master

Revert the modified changes in the Working Tree

  • Make changes to 6.txt and add some content.
  • To revert the changes from the working tree on this file
git checkout -- 6.txt

Git Branches

  • The default branch of git is master
  • Now lets try to create some branches.
mkdir ecommerceapp
cd ecommerceapp
git init
  • Now lets create basic folder structure
mkdir src
mkdir test
mkdir docs
touch Readme.md
touch src/main.py
touch test/main.py
touch docs/main.md
  • Now commit these changes
git add -A
git commit -m "Initial Folder Structure Created"
  • Now this ecommerce application development is agile, We need create the branches for sprints. For now we need to create a branch called as sprint-1
git branch sprint-1
git branch 
git checkout sprint-1
  • To create a branch called sprint-1 and move the head to sprint-1
git checkout -b sprint-1
  • Sprint-1 Developement has made some commits
echo "Sprint 1 Started" >> src/main.py
git add .
git commit -m " Feature 1 completed"

echo "Sprint 1 Started Testing" >> test/main.py
git add .
git commit -m "Feature 2 completed"

git log
  • Now checkout to master branch and then back to sprint-1
git checkout master
git checkout sprint-1

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Network Integration by Acurax Social Media Branding Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%