Git notes (3) – tagging

To tag all files at a current point in time (e.g. to track a release), use:

git tag -a tagname -m "tag description"

To view current tags:

git tag

To show commits associated with a tag:

git show tagname

To push a tag to a remote repo:

git push remotename tagname

Git notes (2): Checking out a branch

Continuing from other notes here.

To checkout a branch:

Clone a repo:

git clone user@server:reponame.git

Fetch all branches:

git fetch remote_name

List all available branches:

git branch -v -a

Checkout required branch:

git checkout -b branch_name remote_name/branch_name

Fetch all changes on branch:

git fetch

 

Committing file deletes to Git

My normal git usage pattern is:

git add .
git commit -m "commit message"

and then when needed:

git push remotename master

The trouble with ‘git add .’ is that is doesn’t stage any deleted files for committing. You can see this if you do a ‘git status’ and you’ll see it list deleted files, but listed as not staged:

$git status
# On branch master
# Changes not staged for commit:
#  (use "git add/rm " to update what will be committed)
# deleted: ...

You’ll notice the comment mentions to use ‘git rm’ to delete files from the repo, but if you’ve deleted files locally, you can either do a ‘git rm filename’ for each of the locally deleted files, or more simply, do this to pick up all changed files for staging, including deletes:

git add -A