Git: Amending last commit

If you accidentally forget to add a file or need to make an additional change to a file when working with git, don’t fret, the solution is simple.

1. Make the change and add it locally with

git add .

2. Commit the change with

git commit --amend

3. You can then verify that this second commit has updated the previous one by running a

git log --stat
Advertisements

Git: Ignoring files

You can ignore files on a project level or have a global ignore file. Git will recursively ignore the specified file patterns.

1. Create a file in a safe location that wont be deleted easily.

$ vi ~/.gitignore_global

2.  Add the following commonly ignored files and directories.

# Eclipse #
target/
bin/
bin-debug/
.svn/
html-template/

# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# OS generated files #
######################
.DS_Store
ehthumbs.db
Thumbs.db

Ignoring a directory in git: directoryName/
Ignore a file in git: *.jar or .DS_Store

3. The last step you need to do is associate this file in the git config.

git config --global core.excludesfile ~/.gitignore_global

This will create an entry in your ~/.gitconfig file.

Reference:
Git Ignore Doco