Git

Branches
- Master branch ... "dev"

- Development branch ... task name. E.g. "INT-102"

- Creating a new branch ... git checkout -b INT-102

- Creating a new branch off from another branch ... git checkout -b New_branch Base_branch (read:

☀http://stackoverflow.com/questions/4470523/git-create-a-branch-from-another-branch)

- Switching branch ... git checkout branch-name

- Delete local branch ... git branch -d branch-name

Syncing
- Update the changes in repository into your local copy ... git pull

Merge
- Merge dev (master) into your branch - If you have a conflict
 * 1) First, update dev ... git checkout dev
 * 2) git pull
 * 3) Then go back to your branch ... git checkout your_branch
 * 4) Now you merge dev into your branch ... git merge dev
 * 5) Auto-commit message appears in VI editor.
 * 6) Just :wq and its auto commit.
 * 1) Edit the conflicted files locally
 * 2) git status tells you what to do (add and commit to resolve conflict).

Commit
- add then commit! "git add.""git commit -m 'comment (see below for format)'"

- Commit message: In format where the first line is "INT-123: "general short description of the changes", then one empty line, and then long description of your changes

To see history of commits in local repository
$git log origin/INT-102..HEAD

Pull Request
- I do not know why we do this. I guess this is for review.
 * 1) Make your branch up-to-date with respect to dev(master) branch.
 * 2) Push to your branch ... git push origin YOUR_BRANCH_NAME
 * 3) Go to github and go to your branch ... https://github.com/Wikia/mercury/tree/YOUR_BRANCH_NAME
 * 4) http://kaworu.jpn.org/kaworu/2013-04-23-1.php

A: Use Rebase
Step 1: in your feature branch: git rebase -i origin/ (git rebase -i origin/dev)

Step 2: mark your main commit (usually the first one) as "pick", and other commits as "squash"

Step 3: write a summary commit message

Step 4: push to origin with force! (git push --force)

B: Use Reset
Step 1: You commit and push everything. You are on branch.

Step 2: Find SHA you want to go back.

Step 3: git reset --soft SHA

Step 4: commit & force push (git push --force origin YOUR_BRANCH)

https://git-scm.com/blog/2011/07/11/reset.html

https://git-scm.com/blog

C: Use Reset part2 (set to HEAD of dev and apply diff)
Step1: You have to have a diff of your current dev and current branch (assume branch has all dev change merged) ... git diff origin/dev..origin/INT-102 > /tmp/INT-102.diff

Step2: You are in your branch ... git checkout YOUR_BRANCH

Step3: (Just in case) git fetch origin

Step4: Make your branch to point to a head of dev ... git reset --hard origin/dev

Step5: git push --force origin INT-102

Step6: Then apply diff ... git apply /tmp/INT-102.diff

Step7: add and commit.

something.