| new skills - Team Nuggets
New Training: Implement Source Control with Git
In this 9-video skill, CBT Nuggets trainer Ben Finkel teaches you how to manage your source code history and versioning by using git. Learn how to use git commands, such as git init, git checkout, git reset, and git revert. Gain an understanding of version control and the git status of files: unmodified, modified, and staged. Watch this new Cisco training.
Watch the full course: Cisco CCNP Automating Cisco Enterprise Solutions
This training includes:
- 9 videos
- 1 hour of training
You’ll learn these topics in this skill:
- Understanding Version Control and Git
- Installing Git and Initializing a Repository
- Staging and Committing Files
- Viewing Repository History
- Comparing Changes with Git diff
- Git Checkout and Detached Head
- Git Reset and Revert to Undo Changes
- Untracking and Unstaging Files
- Using Git Summary
What is the Difference Between Git Reset and Git Revert?
The git commands reset and revert share the same purpose: to rollback commits of a git repository to a previous state. But they perform these rollbacks in a fundamentally different way.
When you use git reset, the head of the repository points back to a previous commit. So, if you made four commits to a repository and want to remove the last one, you execute git reset while specifying the third commit. This is a destructive rollback, which means that the fourth commit is now gone forever. For this reason, git reset is often not your best choice for making rollbacks.
As opposed to git reset, git revert performs a nondestructive rollback. It does this by reverting a previous commit but still leaving it in the repository. So, using our previous example, to revert the fourth commit we would execute git reset while specifying the fourth commit. You can also revert a range of commits if you have many to revert.