Posts Tagged: "git"

List of Git commands

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 […]

How to rename a local Git branch?

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 […]

How to undo the most recent local commits in Git?

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 […]

How to undo ‘git add’ before commit?

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 […]