শনিবার, ১৮ জুন, ২০১১

git

for install: http://veerasundar.com/blog/2011/06/git-tutorial-getting-started/



To see the list of git commands

git help

To see help on a git command


git help COMMAND_NAME

Configure your GIT first time


git config --global user.name "Your Full Name"
git config --global user.email "name@therapservices.net"

Configure your GIT to get colorize output


git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto

Clone your project


git clone git://masum/therap therap

Clone a bare repository for publishing (for team leads):

git clone --bare git://masum/therap therap

Add release branch

git branch --track release origin/release

Delete branch

git branch -D BRANCH_NAME

Add other’s repo as remote branch

git remote add -t master -t release otherperson git://otherperson/therap

Fetch/merge master from otherperson

git checkout master
git fetch git://otherperson master:master
git merge otherperson/master

See all the tags (usually used to mark releases)

git tag -l

See list of all commits from a particular release tag to now

git log --no-merges ..HEAD
git log --no-merges v7.2.4..HEAD

See list of all commits between two release tags

git log --no-merges ..
git log --no-merges v7.2.3..v7.2.4

See which files you are changing

git log --stat

See change details too

git log -p --stat

Viewing the changes you have made since last commit

1) git status
2) git diff
3) git diff --cached
4) git diff HEAD
  1. See status of all files changed or added
  2. See the changes that you have made but not added, changes in a file after the last git add is also
  3. See the changes that you have added to commit, changes done in working directory but not added are not shown
  4. See all changes you have made since last commit (HEAD)
Adding files for commit

1) git add filePath
2) git add filePattern
3) git add .
4) git add web/WEB-INF/
5) git add *.java
  1. Adding a single file
  2. Adding multiple files
  3. Adding all files you have changed, give the command from your project root
  4. Adding all files under web/WEB-INF directory
  5. Adding all changes to java files

Reset/Undo Changes of a file

git checkout HEAD filepath
or git checkout -- filepath

Undo Commit and Keep Changes:

git reset --soft HEAD^

To see who, when added/modified each line of a file

git blame 

Make changes in commit message before pulled by anyone else

git commit --amend

More information on git: http://git-scm.com/

Date format match with regular expression

import java.util.regex.Pattern
import java.util.regex.Matcher
......
.........

boolean isValidDate(String dates){

//String DATE_PATTERN = "(0?[1-9]|1[012])/(0?[1-9]|[12][0-9]|3[01])/((19|20)\\d\\d)"; // for simple

String DATE_PATTERN = "(((0[13578]|1[02])\\/(0[1-9]|[12]\\d|3[01])\\/((19|[2-9]\\d)\\d{2}))|((0[13456789]|1[012])\\/(0[1-9]|[12]\\d|30)\\/((19|[2-9]\\d)\\d{2}))|(02\\/(0[1-9]|1\\d|2[0-8])\\/((19|[2-9]\\d)\\d{2}))|(02\\/29\\/((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))"

// detail solve for 31 problems/ leap year problem

Pattern pattern = Pattern.compile(DATE_PATTERN);

Matcher matcher = pattern.matcher(dates);

if(!matcher.matches()){

return true;

}

else {

return false;

}

}

System.out.println(isValidDate(06/20/2012)); // true



help from .....link