Branch is a name given to the commit. Internally, it is pointer to the commit object. By default, this name/pointer is master. Every time you make a new commit, this pointer moves forward.
In Git terminology, each machine or location is called a remote, and each one may have one or more branches. Most often, you'll just have one, named origin. To list all the remotes, run
$ git remote To see which locations these remote names are shortcuts for, run
$ git remote -v origin git@github.com:foocoding/Git.git (fetch) origin git@github.com:foocoding/Git.git (push)
Each remote has a directory under git/refs/remotes/:
$ ls -F .git/refs/remotes/
-
To delete a local branch, whether tracking or non-tracking, safely: git branch -d
-
To delete a local branch, whether tracking or non-tracking, forcefully: git branch -D
-
To delete a remote-tracking branch: git branch -rd /
-
To create a new local non-tracking branch: git branch []
-
To create a new local tracking branch: (Note that if is specified and is a remote-tracking branch like origin/foobar, then the --track flag is automatically included) git branch --track [<start-point] Example: `git branch --track hello-kitty origin/hello-kitty
-
To delete a branch on a remote machine: git push --delete
-
To delete all remote-tracking branches that are stale, that is, where the corresponding branches on the remote machine no longer exist: git remote prune
-
To check the status of the git repository. (which files are staged, added to the commit, etc.) git status
-
To see the log of previous 'n' commits, git log -n
-
To restore the file to the version of latest commit git checkout --
-
To see the difference between the local repository and the latest commit (HEAD) git diff [filename]
-
THIS IS DANGEROUS!!: To remove the file from both working directory and git git rm
-
To remove the file from git tracking, but still keep it in the working directory: git rm --cached