Basic Development Flow

1) Get up to date

git checkout master
git pull

2) Create new branch for feature

git checkout -b [ticket_no]/features/[feature_name]

3) Do a bunch of work

git add some files that have changed or added
git rm some files that have been removed

and then run test cases if you have.

4) Commit often

git commit -m "a comment about what you changed "

5) Keep up to date

git checkout master
git pull

6) Rebase master back into the feature branch

git rebase master [ticket_no]/features/[feature_name] 

This will put you back into your feature branch, you may need to resolve conflicts here.

7) Integrate your feature into master, Make sure your branch is up to date with master

git checkout master
git merge --no-ff [ticket_no]/features/[feature_name]
git push origin master

There should be no conflicts on master, they have been handled by keeping the feature branch up to date.
If the push to master fails, then someone beat you to it!
Simply go back and do the ‘Keep up to date’ step then try to integrate your feature into master again.

rebase master back into the feature branch

git rebase master [ticket_no]/features/[feature_name]

This will put you back into your feature branch
You may need to resolve conflicts here.

error: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://xxxx@xxxx.xxxx/xxxx/xxxx.git/info/refs

Some time this error occur when you run git clone command:

error: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://xxxx@xxxx.xxxx/xxxx/xxxx.git/info/refs

fatal: HTTP request failed

To get rid of from this error you need to run only one following command:

export GIT_SSL_NO_VERIFY=1

Now you can do git clone and it should work fine.

Initialize Git in Ror project

1. Create project then initialize using following command:

  git init
  git add .
  git commit -m "Initial commit"

Optional step: Update the README file to be more helpful and descriptive.

  git mv README.rdoc README.md
  git commit -a -m "Improve the README"

2. Make a repository at Github and push it up.

  git remote add origin [repository path]
  git push -u origin master

Some Common Git commands:

Change username and email

  git config --global user.name "<username>"
  git config --global user.email "<email address>"

For undo the changes of Git

But chages are not commited yet :

  git checkout -f

For creating and moving to new branch:

  git checkout -b <branch name>

For deleting branch:

git branch -d <branch name>

and for deleting without merging the branch

git branch -D <branch name>

For commiting all modified files without use of git add command as a short cut:

git commit -a -m "<message of commit>"

For merging

git merge <branch name>

For reverting to any no of previous commits:

  git reset --soft HEAD~<no of commits to revert>
  git push origin master --force

Check Git Settings

 git config --list 

Remove Git Remote

 git remote rm destination 

Discard conflicts of git pull request

 git reset --merge