1. Fetching Updates: git fetch
Summary: Understand how git fetch retrieves the latest changes from a remote repository without merging them into your current branch. Learn the difference between git fetch and git pull, and how to use fetch to inspect changes before integrating them.
Commands:
git fetch origin
git fetch origin <branch-name>
2. Undoing Changes: git checkout vs. git restore
Summary: Explore how to undo changes in your working directory using git checkout and git restore. Weโll discuss when to use each command, especially in the context of uncommitted changes.
Commands:
git checkout -- <file-name>
git restore <file-name>
git restore --staged <file-name>
3. Tagging Commits: git tag
Summary: Learn how to use git tag to mark specific commits as milestones in your project. Weโll cover both lightweight and annotated tags, and how to push tags to remote repositories.
Commands:
git tag <tag-name>
git tag -a <tag-name> -m "Message"
git push origin <tag-name>
4. Deleting Remote Branches: git push --delete
Summary: Discover how to remove obsolete branches from remote repositories using git push --delete. Weโll also look at how to safely delete local branches that have already been merged.
Commands:
git push origin --delete <branch-name>
git branch -d <branch-name>
5. Creating Aliases: git config alias
Summary: Speed up your workflow by creating custom aliases for your most-used Git commands. Weโll walk you through setting up simple and complex aliases, making your command line experience more efficient.
Commands:
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
6. Interactive Staging: git add -p
Summary: Learn how to use git add -p to stage changes interactively, allowing you to review and selectively add portions of files to your commit. This command is essential for crafting clean, precise commits.
Commands:
git add -p
7. Handling Submodules: git submodule
Summary: Explore how to work with Git submodules to manage dependencies in your projects. Weโll cover adding, updating, and removing submodules, as well as best practices for working with them.
Commands:
git submodule add <repository-url>
git submodule update --init --recursive
git submodule deinit -f --all
8. Resolving Merge Conflicts: git mergetool
Summary: Discover how to simplify conflict resolution using git mergetool. Weโll discuss configuring a merge tool, launching it during conflicts, and best practices for resolving complex merges.
Commands:
git mergetool
git config --global merge.tool <tool-name>
9. Saving Commits for Later: git stash save
Summary: Master the use of git stash save to create multiple stashes with custom names, making it easier to manage different work-in-progress changes.
Commands:
git stash save "Work on feature X"
git stash list
10. Cleaning Up Untracked Files: git clean
Summary: Use git clean to remove untracked files and directories from your working directory. Weโll cover how to safely preview the files to be removed and how to delete them.
Commands:
git clean -n
git clean -f
git clean -fd
Happy coding! ๐
shop Link : https://buymeacoffee.com/pratik1110r/extras
LinkedIn : https://www.linkedin.com/in/pratik-tamhane-583023217/
Behance : https://www.behance.net/pratiktamhane
Top comments (0)