Create the new file in git directory using git touch command.
$ touch
git rebase Command
The git rebase command is used to reapply commits on top of another base commit, helping to maintain a clean and linear project history.
Basic Usage:
git rebase
This moves your current branch’s commits on top of the .
Lets you edit, squash, or reorder the last 3 commits.
Abort a Rebase (If Something Goes Wrong)
git rebase --abort
Continue After Resolving Conflicts
git rebase --continue
Skip a Commit (If There's an Issue)
$ git --skip
When to Use rebase Instead of merge?
- Use git rebase when you want a clean, linear history.
- Use git merge when you want to keep a record of merge commits.
Uses of Git Branch:
Parallel Development – Multiple team members can work on different features simultaneously without interfering with each other.
Feature Development – Developers can create a new branch to add a feature and merge it later when it's complete.
Bug Fixing – A separate branch can be used to fix bugs without disrupting ongoing development.
Code Isolation – Changes can be tested in a branch before merging into the main branch.
Version Control – Helps maintain different versions of the project for releases or experiments.
Collaboration – Developers can share their branches with others for review before merging.
Common Git Branch Commands
-git branch – Lists all branches.
-git branch <branch-name> – Creates a new branch.
-git checkout <branch-name> – Switches to the specified branch.
-git switch <branch-name> – Alternative way to switch branches.
-git merge <branch-name> – Merges a branch into the current branch.
-git branch -d <branch-name> – Deletes a branch.
git stash Command:
The git stash command is used to temporarily save (stash) changes that are not yet committed, allowing you to switch branches or perform other Git operations without losing your work.
Common git stash Commands:
git stash – Stashes changes (saves them temporarily).
git stash list – Shows a list of stashed changes.
git stash apply – Reapplies the latest stash without removing it.
git stash pop – Reapplies and removes the latest stash from the list.
git stash drop – Deletes the latest stash without applying it.
git stash clear – Removes all stashed changes.
git cherry-pick Command:
The git cherry-pick command is used to apply a specific commit from one branch into another, without merging the entire branch.
Common git cherry-pick Commands:
git cherry-pick <commit-hash> – Applies a specific commit to the current branch.
git cherry-pick -n <commit-hash> – Applies changes but does not create a commit.
git cherry-pick --continue – Completes a cherry-pick after resolving conflicts.
git cherry-pick --abort – Cancels an in-progress cherry-pick.
Top comments (0)