Doing
Git
Right

Use .gitignore

# Comment can be written like this one

# excluding directory
log/
path/to/directory/file.ext

# Common setting
*.log

# Excluding using RegEx
## exclude all files having 'p' and '1' at the end of its name
*.[p1] 

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Windows shortcuts
*.lnk

# Windows Recycle Bin used on file shares
$RECYCLE.BIN/

# IDE/Editor specific files/directories
.idea
*.sublime-project
*.sublime-workspace
.sublime-grunt.cache

# Composer files
composer.phar
/vendor

# Node modules
/node_modules

Gitignore Minified/Uglified files*



# ignore minified files
assets/css/app.min.css
assets/js/app.min.js

Use compiling tools that has config files like

gulpfile.js

Gruntfile.js

koala-config.json

 

and throw un-compiled files only

* you can throw minified files of third party libraries, what you don't change, and use as they are

Use .editorconfig

# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
indent_size = 4

[{.jshintrc,*.json,*.yml}]
indent_style = space
indent_size = 2

[{*.txt}]
end_of_line = crlf
  • .doc, .docx etc.
  • .xls, .xlsx etc.
  • .pdf etc.
  • .jpg, .gif etc.
  • .zip, .rar etc.

Binaries are discouraged

Use markdown/text files

  • .txt
  • .md,.markdown
  • .svg

markdown _cheatsheet_

Empty directory in Git

always untracked, unless there is a file inside

We recommend using a placeholder file inside

so that git can identify the directory as a filled one.



$ touch .gitkeep

A blank .gitkeep file is preferred

One Task per Commit

don't mix up multiple



$ git checkout -b exp-style

$ git add -A
$ git commit -m "Experiment with background image"

Go for a branch if it's experimental

One Task per Commit

don't mix up multiple



$ git checkout -b module/district

$ git add -A
$ git commit -m "Initiate District module"

Go for a branch while dealing with separate module/feature

One Task per Commit

don't mix up multiple



$ git add path/to/district.ext
$ git commit -m "Fix District module with new data"


$ git add path/to/district.ext
$ git commit -m "Fix District module with design issues"


$ git add path/to/district.ext
$ git commit -m "Fixe database connectivity in district module"

Go for a separate commit for each different task

One Task per Commit

don't mix up multiple



$ git add --patch filename.ext

Go for a separate commits, even the task was in same file

Meaningful Commit Message

Commit messages aren’t about the code, they’re about the change itself.

- Logan Johnson (Square Engineering, New York)

Meaningful Commit Message

  • "district fixed"
  • "index changed"
  • "district, division, attendance all are done"
  • "Fix district query with a 3rd party library DIST"
  • "Fix all the links in index file with new repo path"
  • "Fix district module with new data"
  • "Fix division module with new data"
  • "Make Attendance Module"

$ git commit -m "Brief commit message↵
- ↵
- Brief Description what the commit does↵
- ↵
- Issue#12"↵

https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md

following angular contributing note


$ git commit -m "single line commit message"↵

Commit Message Convention

Branching Model

master

develop

feature/{my-feature}

hotfix

v1.0.0
v1.0.1

issue##

Changelog from Commits

https://github.com/orhun/git-cliff/

Bonus Tip



$ git gc

Run garbageCollection once or twice a week

so the git archive stay compressed and fresh

eXtra

There's always a chance to do things in better ways...

Thank You

Mayeenul Islam

Front End Designer, WordPress Developer, Wikimedian and Trekker

 

@mayeenulislam

github.com/mayeenulislam
github.com/nanodesigns

 

google "mayeenul islam"

Made with Slides.com