Archive for December, 2015

A quick and efficient way to demoralize your team

December 21, 2015 Leave a comment

Categories: Interesting 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