1. Configuration 2. Repository Initialization 3. Checking Repository Status 4. Branching 5. Committing Changes 6. Viewing Commit History 7. Remote Repositories 8. Merging and Rebasing 9. Stashing Changes 10. Resolving Conflicts 11. Undoing Changes 12. Viewing Differences 13. Cleaning Up 14. Tags 15. Configuration and Aliases 16. Troubleshooting and Diagnostics 17. Interactive Commands Summary of […]
To rename a local Git branch, you can use the git branch -m command. 1. Rename the Current Branch If you want to rename the branch you’re currently working on, use the git branch -m command followed by the new branch name. Command: git branch -m <new-branch-name> Example: If you’re on the feature/old-feature branch and […]
The commands git pull and git fetch are both used to update your local Git repository with changes from a remote repository, but they behave differently. Here’s a detailed comparison: 1. git fetch Command: git fetch <remote-name> Example: git fetch origin This command will download the latest changes from the remote repository (origin) but will […]
To delete a Git branch both locally and remotely, you need to use the following commands. 1. Delete a Local Git Branch To delete a branch locally, you use the git branch -d or git branch -D command. Command to delete a local branch safely (if it’s already merged): git branch -d <branch-name> Command to […]
If you need to undo the most recent local commits in Git, there are different approaches depending on whether or not you want to keep the changes made in those commits. Here’s a detailed explanation with examples: 1. Undo the Last Commit but Keep Changes in the Working Directory Use git reset with the --soft […]
If you have accidentally added files to the staging area using git add and want to undo it before committing, you can use the git restore or git reset command. Here’s how to do it, with examples: Undo git add for a Specific File If you want to unstage a specific file: git restore --staged […]
When you run git pull, Git merges the changes from the remote repository into your local branch. If there are conflicts or local changes, it may fail or require manual resolution. If you want to force git pull to overwrite your local files, here’s how you can do it: Steps to Force git pull to […]
To check out a remote Git branch, you need to fetch the branch first (if not already available locally) and then create a local branch to track it. Here’s a detailed guide with examples: Steps to Check Out a Remote Git Branch 1. List All Remote Branches To view all branches in the remote repository: […]