DEV Community

Cover image for Intermediate Git commands
Odipo Otieno
Odipo Otieno

Posted on

Intermediate Git commands

Here are some advanced Git commands that can help you manage your code repository more efficiently:

  1. git rebase: This command is used to reapply commits on top of another branch. It is commonly used to keep your branch in sync with the main branch by incorporating changes made by others.

  2. git cherry-pick: This command allows you to apply a specific commit from one branch to another. It is useful when you want to merge a single commit without merging the entire branch.

  3. git bisect: This command helps you find the commit that introduced a bug. You can use it to systematically test each commit to find the one that caused the issue.

  4. git submodule: This command allows you to include a repository within another repository as a subdirectory. It is useful when you want to use code from another repository in your project.

  5. git stash: This command allows you to temporarily save changes that are not ready to be committed. It is useful when you need to switch to another branch or work on a different task but do not want to commit your changes.

  6. git reflog: This command displays a log of all the changes to the Git repository, including changes to branches, commits, merges, and rebases. It is useful for recovering lost commits or finding a deleted branch.

  7. git filter-branch: This command is used to rewrite the history of a Git repository. It can be used to remove sensitive information from commits, split a repository into multiple repositories, or combine multiple repositories into one.

  8. git submodule update: This command updates the submodules in your repository to the latest commit. It is useful when you want to keep the code in your repository up-to-date with the latest changes in the submodule.

  9. git blame: This command displays the author and last modified date of each line in a file. It is useful for identifying who made changes to a particular line of code and when.

  10. git log: This command displays a detailed log of all the commits in the repository. It is useful for tracking changes and understanding the development history of a project.

Top comments (0)