Archive for the ‘git’ Category

Joe – A .gitignore magician in your command line.

March 14, 2016 Leave a comment

A .gitignore magician in your command line. Joe generates .gitignore files from the command line for you.



Categories: git, Interesting, python Tags: ,

Deleting a branch (locally and remotely)

January 13, 2016 1 comment


I needed to delete a git branch but not lose the data on the branch. The desired outcome was to have a new branch that had the same details are the old branch and to empty out the old branch.

My existing state:

master # Empty
old_branch # Has a bunch of files I do not want to lose.

My desired state:

master # Empty
old_branch # Empty
new_branch # Has all the files that were in old_branch.

It was a pretty painless process and straight forward. Git rocks!

$ git branch --list # See local branches
$ git branch --remotes # List the remote-tracking branches.
$ git checkout <old_branch>
$ git branch <new_branch>
$ git branch --delete <old_branch>
$ git push origin --delete <old_branch> 
$ git fetch origin --prune # After fetching, remove any remote-tracking references that no longer exist on the remote.
$ git push origin <new_branch>
$ git checkout master
$ git branch <old_branch> # Now old_branch is the same as master
$ git push origin <old_branch>
$ git branch --remotes
$ git branch --list


Categories: git Tags:

SSL certificate problem: Invalid certificate chain

January 8, 2016 1 comment


When trying to clone a repo I get the following error:

$ git clone
Cloning into 'application'...
fatal: unable to access '': SSL certificate problem: Invalid certificate chain

As I was using a self generated ssl key

$ git config --global http.sslVerify false

Then tried again.

$ git clone
Cloning into 'application'...
Username for '': user
Password for '':
remote: Counting objects: 1397, done.
remote: Compressing objects: 100% (1034/1034), done.
remote: Total 1397 (delta 823), reused 164 (delta 98)
Receiving objects: 100% (1397/1397), 193.55 KiB | 43.00 KiB/s, done.
Resolving deltas: 100% (823/823), done.
Checking connectivity... done.


Categories: git Tags:

git commands – Notes

December 3, 2015 Leave a comment

git commands that I normally forget đŸ™‚

$ git init
$ git add <file>
$ git commit -m "commit message"
$ git rm --cached <file>
$ git status
$ git log
$ git branch
$ git branch <branch name> # To create a new branch
$ git checkout  # To switch to a different branch
$ git log --graph --decorate --pretty=oneline --abbrev-commit
# To create a command alias
$ git config <level> alias.<alias name> '<your sequence of git commands>' 
# eg to create git tree command
$ git config --global alias.tree 'log --graph --decorate --pretty=oneline --abbrev-commit'
$ git tree
$ git tag -d <tag name> # To delete a tag
$ git branch -d  <branch name> # To delete a branch

Getting more and more used to working with git. A few more commands that are useful.

$ git rm -r --cached <dir> # To stop tracking a directory that was already committed.
                           # Does not delete the directory.
$ git update-index --assume-unchanged path/to/file.txt # To stop tracking future changes to a file.

Merging a branch. Assumption that it is a clean branch i.e. everything has been committed.

$ git branch
$ git checkout feature_1
$ git merge feature_2

Deleting Remote and local branches.

$ git branch -d <branch>
warning: deleting branch '<branch>' that has been merged to
         'refs/remotes/origin/<branch>', but not yet merged to HEAD.
Deleted branch <branch>
$ î‚° git push origin --delete<branch>
 - [deleted]         <branch>


# Adding
$ git tag -a v0.1 -m "Initial release 0.1"
# Deleting a local tag
$ git tag -d v0.1
# Deleting a remote tag (after you deleted it locally).
$ git push origin :refs/tags/v0.1


Categories: git