6. Git pull
Fetch changes from a remote repository and merges them into the current branch
The git pull command fetches changes from a remote repository and merges them with your local repository.
Collaborating with others often involves fetching their changes from a remote repository and incorporating them into your local branch. The git pull command simplifies this process.
git pull origin main
7. Git remote
Manage remote repositories
The git remote command allows you to manage the remote repositories associated with your local repository. You can add new remote repositories, remove them, or rename them.
With Git, you can collaborate with developers worldwide by connecting your local repository to remote repositories. The git remote command helps you manage these remote connections.
git remote add origin https://github.com/user/repo.git
8. Git clone
Create a local copy of a remote repository
The git clone command creates a copy of a remote repository on your local machine. You can use it to start working on a project that has already been created.
git clone https://github.com/user/repo.git
9. Git log
Display the commit history
The git log command shows a history of commits made to the repository. It includes the commit message, author, date, and other details.
The commit history contains a chronological record of all changes made to the repository. The git log command offers a detailed view of this history, including commit messages, authors, and dates.
[Read more: Git Log Cheatsheet For a Productive 2023]
10. Git fetch
Download objects and refs from another repository
The git fetch command downloads the latest changes from a remote repository but doesn't merge them with your local repository.
The git fetch command allows you to retrieve changes from a remote repository without merging them immediately. This is useful when you want to review changes before incorporating them.
git fetch origin
11. Git blame
Show who made changes to a file and when
This is a git command that allows developers to determine who last modified a particular line of code in a file, as well as when the modification was made. This command is useful for identifying the author of a particular change, and for investigating the history of a file.
The git blame command helps you pinpoint when and by whom each line in a file was last modified. It's a valuable tool for tracking changes and identifying authors responsible for specific code.
git blame file.txt
12. Git stash
Temporarily save changes that are not ready for commit
This git command allows developers to temporarily save changes to the working directory without committing them to the Git repository. This command is useful for saving changes that are not yet ready to be committed, such as unfinished features or experimental code. Git stash can help developers keep their code organized and easily switch between different code states.
When you're in the middle of a task but need to switch branches or work on something else, the git stash command allows you to save your changes without committing them, preventing loss of work.