views:

37

answers:

1

I want to be able to setup the following git workflow but it confusing as to which are the correct commands to use - rebase, remote, etc?

  1. Clone an open source project where I only have read only access to their git repo
  2. Make changes to the project and save those changes to my private github repo - lets call that 'development'
  3. Once dev changes are stable move them over to 'staging'
  4. Once 'staging' has been tested then move the changes to 'production'
  5. Sync the remote open source project say weekly as its always changing and then start the whole process again.

Thanks

+1  A: 
# clone, create and change to branch development
git clone git://the/open/source/project.git
git checkout -b development

# make changes and commit
git add ...
git commit -m '...'

# several commits later, create a branch named staging and change to it
git checkout -b staging

# after testing, create a branch named production and change to it
git checkout -b production

# syncing ( assuming the remote to be named origin and the branch is named master )
git checkout master
git fetch origin master
git merge origin/master

# repeat the process
Alan Haggai Alavi
-1 you forgot "git add", you forgot something like "git remote add github <url>". And finally, the merge should be after checking out development branch, not master.
mrrtnn
You could have edited the answer. That is why there is an `edit` button! A `git clone` automatically adds a remote tracking branch. The user may want to have a `master` branch which is exactly like the remote. Hence the merge to `master`.
Alan Haggai Alavi
At a reputation of 173, I doubt he could edit your answer.
sleepynate
Ah! My bad. Apologies, @mrrtnn. :-(
Alan Haggai Alavi
+1 you edited :)
mrrtnn
@mrrtnn: Thanks! :-)
Alan Haggai Alavi