Git Demystified - 100+ Essential Commands
Git Demystified - 100+ Essential Commands
bash
bash
$ git init
Initialized empty Git repository in /project/.git/
bash
$ git status
On branch main
Untracked files:
(use "git add <file>..." to include in what will be
committed)
bash
$ git log
commit 1a2b3c Author: Your Name
<[email protected]> Date: Mon Nov 13 12:00
2024
bash
bash
bash
$ git merge feature-login
Auto-merging file1.txt
CONFLICT (content): Merge conflict in file1.txt
Resolve conflicts manually, then:
bash
bash
bash
$ git stash
$ git stash list
$ git stash apply stash@{0}
git stash: Saves changes for later.
git stash apply: Restores stashed changes.
bash
$ git cherry-pick <commit_hash> # Apply specific
commits
$ git rebase main # Reapply commits on top of
another base branch
$ git bisect start # Binary search for bugs
bash
$ cat .git/hooks/pre-commit
#!/bin/sh
echo "Running pre-commit checks..."
bash