0

i am new to rails and am following agile web development with rails 4 book. i am on part 2 of the "Building an application" book, i created a new project in aptana studio 3. and then made a branch using this command "git checkout -b new_feature" the project was called "depot (master)" now it is called "depot (new_feature)" i did a bunch of stage and commits as i went through the material. now i want to merge back to the master branch, i used the command "git rebase master" and it said "fatal: needed a single revision" and second line "invalid upstream master" what does this mean ? i then tried "git merge new_feature" says its already up-to-date. what can i do i would like to merge this branch and then push to github using "git push --force origin master:master" so its up there, then creating another branch off of master to work on something different on the same project, and ill have to push that also, to get graded, but i will start my next assignment off of the first push before i started "something different". any suggestions? still trying to understand this.

  • I'm no git expert, but it appears you're working off of a branch called 'new_feature' and trying to merge back into the master branch. That '-b' flag you passed to checkout indicated that you wanted a new branch, and you even gave it a name. This [SO answer](http://stackoverflow.com/questions/556923/how-to-merge-my-local-uncommitted-changes-into-another-git-branch) may help you. – MarsAtomic Jan 29 '15 at 01:26

1 Answers1

0

If you want to merge the new_feature locally with your master branch, you need to first commit your changes in the new_feature branch, like so:

git add --all
git commit -m "some message"

Then you need to switch to the master branch:

git checkout master

Then you need to merge new_feature with master:

git merge new_feature

Next step, putting it on Github. I assuming you have a Github account, and that you have created a new repo for your project on Github, so now git just needs to know where to send the code. You do this by copy pasting the clone URL off your new github repo, and running this:

git remote set origin git@github.com:yourusername/yourreponame.git

Now you can push your code to github.

git push origin master
trosborn
  • 1,658
  • 16
  • 21
  • when i tried to type "git checkout master" it says "error: pathspec 'master' did not match any file(s) known to git. – Giovanni Luna Jan 29 '15 at 02:03
  • When you run "git branch" what do you get? – trosborn Jan 29 '15 at 02:06
  • i get " *new_feature" – Giovanni Luna Jan 29 '15 at 02:11
  • Okay, that means you do not have the master branch. Instead of running "git checkout master" run "git checkout -b master", this will create a master branch and check it out. – trosborn Jan 29 '15 at 02:17
  • i wonder what happened to my master branch ? kind of scary...lol. so now how do i make it so there is only one " master" project with no branches ? i want to push this to github my professor has a respository by the name of origin. im going to use a command he provided, "git push --force origin master:master" i appreciate the help by the way. – Giovanni Luna Jan 29 '15 at 02:23
  • So, I think part your confusion comes from thinking there is something special about a branch called master. Master is just a name, like new_feature. Normally when you run "git init" a branch called master is created, why it was not in this case is beyond me. – trosborn Jan 29 '15 at 02:28
  • If you want to check to make sure git branch -d new_feature worked, run "git branch" again and see what branches you have ;) – trosborn Jan 29 '15 at 02:29