- Working Truee
- Staging Area (Index)
- History
git diff
git diff --staged
git checkout -- <file>
git reset HEAD <file>
git log -- <file>
git checkout <changeset> -- <file>
git commit <file>
A branch is just a pointer to a SHA-1 hash.
The way Git knows which branch we are on is a special pointer called HEAD. HEAD is a pointer normally points to a branch. Since HEAD usually points to a branch and NOT directly to a commit, it is sometimes called a symbolic pointer. In Git terminology, the HEAD pointer tells us what we have checked out.
git log --all --decorate --oneline --graph
alias graph="git log --all --decorate --oneline --graph"
dit diff <branch 1>...<branch 2>
git merge <branch name>
git branch --merged
git branch -d <branch name>
git merge <branch name>
git merge --abort
# to mark resolution
git add <file>
# to conclude merge
git commit
Usually HEAD points to a branch which in turn points to a commit. When HEAD is instead pointing directly to a commit, we have a detached HEAD state.
git checkout <SHA-1 hash>
git stash
git stash save <stash message>
git stash list
git stash list -p
git stash apply <stash label>
git stash pop <stash label>
When we are working in a repository, a remote is simply a repository in another location from where we are currently working.
When we fetch or push updates we don't need to remember the full location of our remote. Instead, Git can hold a short name or alias to that location. The default first name is origin.
git remote
git remote -v
origin/master
is a specialized branch. it is called a remote-tracking branch
.
The job of this remote-tracking branch is to tell us what the master branch looks like at origin.
The remote-tracking branch
is not the same as a standard local branch.
We can check it out with git checkout origin/master
.
Checking out the remote tracking branch works, but we end up in a detached HEAD state.
git fetch <remote repo>
git merge origin/master
# "git pull" combines "git fetch" and "git merge" into a single command.
git pull
# we are pushing our edit to our remote named origin, and to the master branch at origin.
git push origin master
git remote add <short remote name> <remote URL>
git remote remove <remote name>
git fetch <remote name>
git merge
git push
git branch -a
# displays remote-tracking branches only
git branch -r
git push
- Introduction to Git - Core Concepts: https://youtu.be/uR6G2v_WsRA
- Introduction to Git - Branching and Merging: https://youtu.be/FyAAIHHClqI
- Introduction to Git - Remotes: https://www.youtube.com/watch?v=Gg4bLk8cGNo