Git & GitHub for DevOps

Git & GitHub for DevOps

What is Git?

Git is a popular version control system. It was created by Linus Torvalds in 2005, and has been maintained by Junio Hamano since then.

It is used for:

  • Tracking code changes
  • Tracking who made changes
  • Coding collaboration

What does Git do?

  • Manage projects with Repositories
  • Clone a project to work on a local copy
  • Control and track changes with Staging and Committing
  • Branch and Merge to allow for work on different parts and versions of a project
  • Pull the latest version of the project to a local copy
  • Push local updates to the main project

Working with Git

  • Initialize Git on a folder, making it a Repository
  • Git now creates a hidden folder to keep track of changes in that folder
  • When a file is changed, added or deleted, it is considered modified
  • You select the modified files you want to Stage
  • The Staged files are Committed, which prompts Git to store a permanent snapshot of the files
  • Git allows you to see the full history of every commit.
  • You can revert back to any previous commit.
  • Git does not store a separate copy of every file in every commit, but keeps track of changes made in each commit!

Why Git?

  • Over 70% of developers use Git!
  • Developers can work together from anywhere in the world.
  • Developers can see the full history of the project.
  • Developers can revert to earlier versions of a project.

What is GitHub?

  • Git is not the same as GitHub.
  • GitHub makes tools that use Git.
  • GitHub is the largest host of source code in the world, and has been owned by Microsoft since 2018.
  • In this tutorial, we will focus on using Git with GitHub.


Git and GitHub important Commands

On the forth day, I learned the following things about Git.

  • git init will only track a particular directory in which git is initialized.
  • ls -a .git will show you the hidden file that are created after initializing git.
  • git status will show the status of the files that are newly created, modified or deleted.
  • git add filename OR git add . will add a particular or all the files into the staging area and it can now be tracked them before committing them into Git.
  • git commit -m "add a message" will commit the changes in the git.
  • git commit -am "add a message" will add the files into the staging area and commit it also.
  • git restore --staged filename will move the files from the staging area to the unstaging area. In this way, the data will be reverted back.
  • git log will show the history of all the git commits.
  • git reset hash value will move the data from the committing area to the unstaging area. Provide the previous hash value if you want to delete the next one.
  • git stash will store the data temporarily somewhere in the memory. The changes won't be committed. Instead it has to be added to the staging area and then it can go to the stashing area.
  • git stash push -m "add a message" will store the data temporarily in the git stash.
  • git stash list will show the list of data that are temporarily stored.
  • git stash clear will delete the list of data that are present in the git stash.
  • git stash apply index number will call the stashing in which you want to make changes.
  • git stash drop index number will delete a specific data from the stashing list.
  • git stash pop index number will transfer the specific index number data out of the stashing area so that it can be further committed. It means that the data is now able to be added into the staging area and committed also.
  • rm -rf .git will unintialize the git. It means that all the branches will be deleted from Git.

I'm confident that this article will prove to be valuable, helping you discover new insights and learn something enriching .

???? If you find it helpful, don't hesitate to share it with your network

thank you : )

Roman Burdiuzha

Cloud Architect | Co-Founder & CTO at Gart Solutions | Specializing in DevOps & Cloud Solutions

10 个月

Can't wait to read it! ??

要查看或添加评论,请登录

社区洞察

其他会员也浏览了