Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

This is our default workflow. The central concept of this workflow is that all development occurs in isolated "topic" branches. The "master" branch is kept clean allowing easy branching to address separate features (topics) and bug fixes. Another key feature of this flow is the use of rebases instead of merges to prevent local merge commits.

  1. Update "master" “master” branch.
    Code Block
    > git pull upstream master
    
  2. Create a new feature-branch "feature1" “feature1”
    Code Block
    > git branch feature1 master
    > git checkout feature1
    
  3. Do some work on your feature, add and commit it
    Code Block
    > git add File1, File2
    > git commit -m "Working my feature"
    
  4. OPTIONAL: When you're you’re ready to push up, squash all of your commits together first
    Code Block
    > git reset --soft master
    > git commit -m "unified feature commit"
    
  5. When you're you’re ready to push your work up to get pulled in, make sure you're you’re up-to-date first
    Code Block
    > git checkout master
    > git pull upstream master
    
  6. "master" “master” is now up-to-date. Switch back to your branch and rebase your work on top of the new "master" “master”
    Code Block
    > git checkout feature1
    > git rebase master
    
  7. Push up to github
    Code Block
    > git push origin feature1
    
  8. Issue pull request
  9. When processed, update "master" “master” to pull down your official change, delete "feature1" “feature1”
    Code Block
    > git checkout master
    > git pull upstream
    > git branch -D feature1
    

...

When you rebase your feature on-top of new stuff in your "master"“master”, you may have to handle file merges. Please note that step 4, squashing all of your work into a single commit is encouraged, otherwise you may end-up processing merges on the same file for every commit you're you’re rebasing.

How do you know you're you’re conflicted? Look for the big "CONFLICT" “CONFLICT” in the results when you issue the rebase

...

You can either use your IDE to handle the conflicts or if you've you’ve setup the git merge-tool (http://gitguru.com/2009/02/22/integrating-git-with-a-visual-merge-tool/), issue the following from the command-line

...

Code Block
git rebase --continue

If you've you’ve made a mistake and just want to cancel out of the rebase, issue the following command:

...

When developing a fix or feature across multiple branches, you often cannot just merge one branch onto another. Think of a fix that needs to be applied to versions 1.0, 2.0 and 2.2. Merging would bring in more than your one fix. In this scenario cherry-picking is the answer. Basically it's it’s capturing a patch-file of one commit and applying it to another branch to create a new commit.

Steps to Cherry-pick
Identify the SHA(s) code for the commit you want to pick-over to another branch. git log or your IDE's IDE’s history will work fine.

Code Block
git checkout TARGET_BRANCH
git cherry-pick 724d9acd 3d4fcf9e

...

The second use of reset actually moves the branch to point to another commit. This is often a commit further back in the branch, but can be any commit from any branch, remote or even an orphaned commit in the reflog. You'll You’ll notice we don't don’t specify a file, that's because we're that’s because we’re resetting the branch!

Code Block
git reset --STYLE COMMIT_SHA_OR_NAME

The style of reset you apply makes a huge difference in the result.
--soft
Does not touch the index file nor the working tree at all (but resets the head to <commit>)
(This is great for "squashing" “squashing” several commits together as they're they’re changes are on disk and they're they’re in the staging area (index) ready to be committed.)

--mixed
Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.

(This is useful when you're you’re accidentally added too much to the staging area and just want to reset it)

...

--merge and --keep
These are inbetween a --hard and --soft. I don't don’t use them much, but you can read about them here (https://www.kernel.org/pub/software/scm/git/docs/git-reset.html)

...

Code Block
mkdir pristine && cd pristine
git init

Create a new file "test“test.txt" txt” with the following content:
"the “the brown dog jumped over the lazy fox"fox”

Code Block
git add test.txt
git commit -m "initial commit"

...

edit the test.txt and make the content:
"the “the purple dog jumped over the lazy fox"fox”

Code Block
git add test.txt
git commit -m "brown is out of style"

...

edit the test.txt to make the content:
"the “the brown dog jumped over the lazy turtle"turtle”

Code Block
git add test.txt
git commit -m "brown is out of style"

Now back to your feature, rebase on top of master and you'll you’ll have a Merge!

Code Block
git checkout feature
git rebase master

...