Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
New L4 project with clean history
# Initial setup
git clone -o framework -b develop https://github.com/laravel/laravel.git project-name
cd project-name
git checkout --orphan master
git commit -m "Initial commit"
# Pulling changes
git fetch framework
git merge --squash -m "Upgrade Laravel" framework/develop
# Fix merge conflicts if any and commit
@joecwallace

This comment has been minimized.

Copy link

joecwallace commented Apr 3, 2013

Thanks for this. I've already used it a few times to start new L4 projects.

One thing though: shouldn't there be a git add . between the checkout and commit?

@jahvi

This comment has been minimized.

Copy link

jahvi commented May 3, 2013

Works as expected, it's be nice to add more comments to explain why it works, it took me a while to figure out what --orphan and --squash do

@darronz

This comment has been minimized.

Copy link

darronz commented May 10, 2013

When L4 goes to Master will there be an easy way to switch branches with your script?

@jahvi

This comment has been minimized.

Copy link

jahvi commented May 11, 2013

Just ommit -b develop from the first line and change framework/develop in the last for framework/master

@montogeek

This comment has been minimized.

Copy link

montogeek commented Jun 14, 2013

Thanks @javiervd

@ericmagnuson

This comment has been minimized.

Copy link

ericmagnuson commented Jun 27, 2013

Thanks for this @akuzemchak. I adapted this to work with Laravel setups that have already been worked on and not cloned in the beginning from the Laravel repo. If you don't want to update from the master branch, be sure to change the third line.

git remote add framework git@github.com:laravel/laravel
git fetch framework
git merge --squash -m "Upgrade Laravel" framework/master
# Alternatively, specify a version tag by doing
# git merge --squash -m "Upgrade Laravel" v4.0.5

# Fix conflicts if any
git mergetool
git commit -m "Upgrade Laravel"

# Clean up any files left by fixing conflicts (they shouldn't be tracked at any point).
git clean -n # Make sure everything is correct!
git clean -f
@jahvi

This comment has been minimized.

Copy link

jahvi commented Jul 2, 2013

Just a quick note on doing the same now that laravel is stable, since you're cloning the master branch now you won't be able to run git checkout --orphan master because there's already a branch named master so the steps I take now are:

# Initial setup
git clone -o framework https://github.com/laravel/laravel.git project-name
cd project-name

# Rename pulled master branch
git branch -m master laravel

git checkout --orphan master
git commit -m "Initial commit"

# Pulling changes
git fetch framework
git merge --squash -m "Upgrade Laravel" framework/master
# Fix merge conflicts if any and commit

I think you can even delete the laravel branch but I'm not sure. Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.