Notes on git
This page summarizes git commands that I frequently use.
Branching
Create a new branch
git checkout -b <branch>
This single command is equivalent to the following sequence of two commands
git branch <branch> # create a new branch
git checkout <branch> # switch to the newly created branch
Tagging
Commands related to tagging:
git tag # view existing tags
git tag -a <tag name> -m '<message>' # create an annotated tag
git checkout tags/<tag name> # update repo to a particular tag
Repository Commands
Commands related to the creation of local and remote repositories
git init --bare # create an empty repository
# add a connection to a remote repository
git remote add <name> ssh://<user>@<host>/<directory>
git remote rm name # remove a connection to a remote repo
git remote -v # view connections to remote repos
Viewing
Visualize history
git log --oneline --abbrev-commit --all --graph
Show branches
git branch -a # both remote and local
git branch -r # remote only
Show unmerged branches git branch –no-merge # –merged
Miscellaneous
Miscellaneous commands
git rm <file> # remove a file from the repo
git push <remote site> master # push changes to a remote repot
git checkout <hash #> <filename> # change a file to a specific version
git checkout -- . # discard local changes
Branching Model
Since branches are easier to do in git than in previous source control systems, they are done more often. This blog post describes a branching model to follow.
Using git to push a website to Nearlyfreespeech
This link describes how to create a remote repository on nearlyfreespeech and how to use git to transfer (“push” in git terminology) your local development to it.
git push nfsn master