Git 004 Overview
Git 004 Overview
Core Commands:
1. git init:
2. git clone:
3. git add:
4. git commit:
5. git status:
Shows the current state of the working directory and staging area.
Indicates which files are modified, staged, or unstaged.
Example: git status
6. git diff:
Compares the current working directory with the staged changes or the last commit.
Shows the specific differences between the files.
Example: git diff
1|Page
7. git log:
8. git reset:
9. git checkout:
Fetches changes from a remote repository and merges them into the current branch.
Example: git pull origin main
2|Page
15. git stash:
3|Page
</> Git Commands for Project and Branch Management </>
</s> Branch Management </s>
1. git branch -d <branch_name>: Deletes a local branch after merging it into another branch.
2. git branch -D <branch_name>: Deletes a local branch without merging it, forcing deletion.
3. git checkout -b <new_branch_name>: Creates a new branch from the current branch and
switches to it.
4. git checkout -b <new_branch_name> <start_point>: Creates a new branch from a specific
commit or tag.
5. git merge --no-ff <branch_name>: Creates a merge commit even if the merge could be fast-
forward.
6. git merge --squash <branch_name>: Combines the changes from the specified branch into
a single commit.
7. git rebase -i <start_point>: Interactively reorders, edits, or squashes commits.
8. git cherry-pick -m <parent_number> <commit_hash>: Picks a commit from a parent
branch when there are multiple parent commits.
9. git branch --force <branch_name>: Forces the branch to be updated to the specified
commit, even if it conflicts.
10. git branch --track <remote_branch_name> <remote_name>: Sets up a tracking branch for a
remote branch.
</s> Project Management </s>
11. git config --global user.name "Your Name": Sets your name globally for Git commits.
12. git config --global user.email "[email protected]": Sets your email address globally
for Git commits.
13. git config --global core.editor "your_favorite_editor": Sets your preferred editor for Git.
14. git config --global core.autocrlf true: Automatically converts CRLF line endings to LF on
checkout and LF to CRLF on commit.
15. git config --global core.editor "vim": Sets Vim as the default editor for Git.
16. git config --global color.ui true: Enables colorized output in Git commands.
17. git config --global alias.st status: Creates an alias for the git status command.
18. git config --global alias.co checkout: Creates an alias for the git checkout command.
19. git config --global alias.br branch: Creates an alias for the git branch command.
20. git config --global alias.lg log --graph --pretty=format:'%Cred%h%Creset - %s
%Cgreen(%an%Creset)': Creates a custom alias for a more readable log format.
4|Page
5|Page