Git_Advanced
Git_Advanced
related to git...
version control github gitlab docker compose jenkins continuous integration npm ssh automation
http web services authentication
Beginner Print
Copy
Copy
cheatsheets
Git repository. This command allows users to selectively choose which changes to include in the
commit, effectively enabling them to build commits incrementally by organizing and grouping
related changes together.
Copy
Copy
Copy
Check Status
git status
Check Status for Specific Path
git status <file-path> cheatsheets
advertisement
Copy
Basic Log
git log
One-line Log
git log --oneline
Log by Author
git log --author='Author Name'
Copy
git pull - Fetch from and integrate with another repository or a local
branch. Tutorial
The 'git pull' command is used to fetch changes from a remote repository and merge them into the
current branch. This command is a combination of 'git fetch' (which retrieves updates from a
remote repository) and 'git merge' (which integrates those updates into the local branch). It is
essential for keeping your local repository up to date with the latest changes made by others.
Copy
git push - Update remote refs along with associated objects. Tutorial
The 'git push' command is used to upload local repository content to a remote repository. This
command updates the remote refs with the local commits, effectively sharing changes made by
the developer with the rest of the team. It is essential for collaboration, as it allows all contributors
to access the latest changes in the project.
Copy
advertisement
Intermediate Print
git merge <branch> - Merge specified branch into the current branch.
Tutorial
The 'git merge <branch>' command is used to integrate changes from the specified branch into
the current branch. This operation combines the histories of both branches, allowing you to bring
in updates, features, or bug fixes made on the specified branch while preserving the history of
commits.
Copy
git rebase <branch> - Reapply commits from one branch onto another.
Tutorial
The 'git rebase <branch>' command is used to move or combine a sequence of commits to a new
base commit, which allows for a cleaner project history by incorporating changes from one branch
onto another. It's particularly useful when you want to update a feature branch with the latest
updates from the main branch before merging.
cheatsheets
Copy
Copy
Copy
git fetch - Download objects and refs from another repository. Tutorial
The 'git fetch' command downloads the latest changes from a remote repository without merging
them into the current branch. It updates the local copies of remote branches, allowing users to
review changes before integrating them into their local codebase.
Copy
advertisement
Copy
Copy
Create a tag
git tag v1.0
Delete a tag
git tag -d v1.0
Copy
git diff - Show changes between commits, commit and working tree,
etc. Tutorial
The 'git diff' command is used to show the differences between various states of your repository. It
can be applied to compare changes between commits, between the working tree and index, or
between your current working directory and the last commit. This helps developers understand
what modifications have been made, review changes before committing, or assess differences
between branches.
Copy
Show changes between the working directory and the last commit
git diff HEAD
Copy
advertisement
Advanced Print
git reflog - Show reference logs. Tutorial
cheatsheets
The 'git reflog' command is used to show the reference logs in a Git repository. It tracks updates to
the tips of branches and what commits were checked out, providing a record that can help restore
lost commits or simply analyze the changes made within the repository over time. The reflog is
particularly useful in situations where commits might have been lost due to a bad rebase, reset, or
other operations that alter the project history.
Copy
View Reflog
git reflog
Clear reflog
git reflog expire --expire=now --all
git bisect - Use binary search to find which commit introduced a bug.
Tutorial
Git bisect is a powerful tool used to find the specific commit that introduced a bug by employing a
binary search algorithm. It allows developers to efficiently narrow down the range of commits that
could potentially contain the problematic code, making it easier to identify when the issue was
introduced and subsequently resolve it.
Copy
Copy
Initialize a Submodule
git submodule add <repository-url> <path>
Update Submodules
git submodule update --init --recursive
Copy
cheatsheets
The 'git archive' command is used to create an archive file, such as a tar or zip file, that contains
the contents of a specific tree (a snapshot of the project at a particular point in time) in your Git
repository. This is useful for creating a release package or sharing specific versions of your project
without needing to expose the entire repository history.
Copy
advertisement
git merge --no-ff - Create a merge commit even if the merge resolves as
a fast-forward. Tutorial
The 'git merge --no-ff' command is used to create a merge commit in Git, even when the merge
could be resolved with a fast-forward. This is useful for maintaining a clearer history in a project,
as it explicitly shows when a feature or branch was integrated while preserving the context of that
integration.
Copy
example1
git checkout main
git merge --no-ff feature-branch
example2
git checkout develop
git merge --no-ff new-feature
Copy
cheatsheets
Git repository. This feature is useful for working on different branches at the same time without
having to switch back and forth, enabling parallel development and testing of different features or
bug fixes.
Copy
Remove a worktree
git worktree remove ../new-feature-branch
Copy
git blame <file> - Show what revision and author last modified each line
of a file. Tutorial
The 'git blame <file>' command is used to display the last modification information for each line of
a specified file in a Git repository. It shows which commit and author modified each line, thereby
helping developers understand the history and context behind changes made to the file. This
command is particularly useful for tracing bugs and understanding the evolution of code.
Copy
advertisement