# Git
It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows. - Home
Git branches are pointer to a commit - Git Branches Have No Rules - Git Branches: Intuition and Reality
see also
- git absorb / HN - You have a feature branch with a few commits. Your teammate reviewed the branch and pointed out a few bugs. You have fixes for the bugs, but you don’t want to shove them all into an opaque commit that says fixes, because you believe in atomic commits.
- git worktree / HN - Worktrees allow you to have a separate working directory (and staging area) for each branch you’re actively working on.
- Git rebase, what can go wrong?
- Git In Two Minutes
- lazygit - A simple terminal UI for git commands
- vs BitKeeper
- git-flow (2010) - This was terrible at the time and it remains terrible now. Not to be confused with GitHub flow which is simpler.
- Committing without git
Config
git config --global user.name "Your Name"
git config --global user.email "youremail@yourdomain.com"
git config --list
Diff tool
- Configuring diff tool
- How do I view ‘git diff’ output with my preferred diff tool/ viewer?
- How Git cherry-pick and revert use 3-way merge
Meld understands git and provides navigating around the recent changes.
meld .
mtime
see Why isn’t Git preserving modification time on files? - short to stay compatible with make
If you wan’t original times (rather than checkout times) use this tool
sudo apt install git-restore-mtime
cd [repo]
git restore-mtime
Basic Cmd
Undo last commit, keeping change
$ git reset --soft HEAD~ # Undo the last commit but leave the changes in the staging area
$ git reset HEAD^
see also: How do I undo the most recent local commits in Git?
Abort merge
git reset --hard HEAD
git clean -fd
Checkout branch
# without using origin/xx
git checkout <branch from above>
Add origin as new github repo
git remote add origin git@github.com:yduf/<repo>.git
Remove origin
git remote rm origin
change a Git repo’s origin
git remote rename origin upstream
git remote add origin git@github.com:user/fork.git
# then point the master branch to your new remote (as it has been automatically changed to upstream)
git config branch.master.remote origin
Written on October 30, 2018, Last update on November 1, 2024
git
diff
vcs