-
Initializing a Git Repository
We started by installing Git and initializing it within a project. When you run the initialization command, Git creates a hidden.gitfolder that stores all version history data. -
Setting Up a Remote Repository
Establishing a remote repository is crucial for backing up your local work and collaborating with team members. Connect your local repository to a remote server with the following command: -
Pushing Local Changes
With the remote repository in place, you can push your local changes to the remote server, ensuring your work is safely stored and shared: -
Working with Branches
Branching allows you to develop new features and fixes independently from the main codebase. After completing your work on a branch, you can commit your changes and merge them back into your primary branch. -
Using Rebasing
Rebasing is an alternative to merging that rewrites the commit history. Use the simple rebase command as shown:For more refined control, an interactive rebase lets you modify commits: -
Undoing Changes
This article also covered different techniques to revert changes safely:-
Revert Command: Creates a new commit that undoes previous changes.
-
Reset Command:
-
A soft reset moves the HEAD pointer back while keeping your changes intact:
-
A hard reset completely removes the changes:
-
A soft reset moves the HEAD pointer back while keeping your changes intact:
-
Revert Command: Creates a new commit that undoes previous changes.
Remember: Whether reverting or resetting, understand the impact of each command on your commit history before applying it in shared repositories.