How do you change the git repository a rail app is pushed to? I know that this is possible because I did it a few weeks back.
Basically I have two very different versions of a app on my local machine. I would like the initial app to still point to the old repository. However, the new version needs to be placed in a completely separate repository.
When I run git init in myapps/old_app/ it puts Reinitialized existing Git repository in /Users/jamespollard/rails/old_repository/.git/
AND
When I run git init in myapps/new_app/ it puts Reinitialized existing Git repository in /Users/jamespollard/rails/new_repository/.git/
However, when I try and git push anything to the repository, it still goes to the old_repository.
Updates
If I enter $ git remote origin set-url git#github.com:mygithub/myapp.git
I get
error: Unknown subcommand: origin
usage: git remote [-v | --verbose]
or: git remote add [-t <branch>] [-m <master>] [-f] [--mirror=<fetch|push>] <name> <url>
or: git remote rename <old> <new>
or: git remote rm <name>
or: git remote set-head <name> (-a | -d | <branch>)
or: git remote [-v | --verbose] show [-n] <name>
or: git remote prune [-n | --dry-run] <name>
or: git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]
or: git remote set-branches <name> [--add] <branch>...
or: git remote set-url <name> <newurl> [<oldurl>]
or: git remote set-url --add <name> <newurl>
or: git remote set-url --delete <name> <url>
-v, --verbose be verbose; must be placed before a subcommand
If I enter $ git remote set-url git#github.com:mygithub/myapp.git I get the same error message as above (minus the origin error). In either case, if I run git push origin master it still pushes to the old repository. I've tried adding the new repository again with the same name, but I get a error (which i would expect) saying that it already exists.
Create a new repository in GitHub for you new app, if you haven't already. Make that new repository as origin to your new repository:
git remote add origin <github_url>
If the remote already exists, you might have to git remote set-url origin <github_url>
Now, push to the repo.
I ran into a pretty similar situation few months ago. On the new version of the app there is a .git folder (which was also copied along with all other files when you copied the app). Heroku needs the information from .git to see if anything has changed. So when it 'reinitialized', heroku thinks its the same app.
So here's what I did that resolved the problem.
Copied the entire app folder.
Changed app name wherever they appear (mostly in config folder, google it for a list)
Chang secret.yml file (get a new key by rake secret) or secret token if older version
of rails.
Most importantly, there should be a .git folder in your app folder (it maybe hidden).
Delete that .git folder (it contains git info of the old app)
Initialize a new git, git init
and then commit and push.
Your new app should be a separate app now.
I think this might work if on heroku, worth a try:
git remote rm heroku
git remote add heroku git#heroku.com:yourappname.git
or you can try this
1). open a terminal
2). Go to your_app_directory/.git/config
3). Once you open the config file then edit as follows:
Change
url = git#heroku.com:old_app_name.git
to
url = git#heroku.com:new_app_name.git
Obviously substituting your apps old name to its new name. Hope it helps
If you take a peek at your .git/config file, you see / check that the url is still pointing to the old remote
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = <old_github_url>
so you wish to keep the old remote. let's call that oldremote.
First thing you can do is the rename the remote with :
git remote rename origin oldremote
Now you can add the new remote with :
git remote add origin <new_github_url>
From now on, pushing normally with just git push will push to the new remote. git push oldremote SHA to push to the old remote
remote reference : http://help.github.com/remotes/
Related
I'm having some trouble setting up the bitbucket repo
humantoast#rails-tutorial:~/workspace/hello_app (master) $ git remote add origin git#bitbucket.org:HumanToast/hello_app.git
fatal: remote origin already exists.
.
humantoast#rails-tutorial:~/workspace/hello_app (master) $ git push -u origin --all
conq: repository does not exist.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I just want to say that I tried the following and it seems to have worked. Note that '<username>' refers to your username. If on a numbered list, replace <username> with your username.
Enter the numbered commands below into the terminal. 'Result' is the output the terminal showed after the command was entered
git remote -v
Result
origin git#bucket.org:/hello_app.git (fetch)
origin git#bucket.org:/hello_app.git (push)
git remote rm origin
Result
No output in the terminal
git remote add origin git#bitbucket.org:<username>/hello_app.git
git push -u origin --all # pushes up the repo and its refs for the first time
Result (note the 3 dots below refers to output on the terminal that I excluded due to it potentially containing confidential information)
.
.
.
Are you sure you want to continue connecting (yes/no)?
yes
Result
.
.
.
To git#bitbucket.org:<username>/hello_app.git
[new branch] master -> master
Branch master set up to track remote branch master from origin.
That seems to have done the trick. I wasted a day stuck so early in the book.
I'm trying to git push origin master using Michael Hartl's rails tutorials (first_app), but i'm getting this problem:
[first_app]$git push origin master
ERROR: Permission to railstutorial/first_app.git denied to tomkim
fatal: The remote end hung up unexpectedly
I've re-entered an SSH key, but that's not it. I've never had this problem before, but now I am.
Help's greatly appreciated.
You need to add your own repo as the remote (of course you need to create a first_app repo on Github first):
$ git remote rm origin
$ git remote add origin git#github.com:tomkim/first_app.git
$ git push -u origin master
And tomkim is your github account name, right? If not, change it to yours.
I was able to figure this out. I noticed that the origin was showing "railstutorial/first_app.git", when that it should've been tomkim310/first_app.git. The problem to begin with was follow Hartl's tutorial, I was just typing as he was going. Simply doing a new "git remote add origin git#github.com:tomkim310/first_app.git" does not do the trick.
I verified this by typing in: git remote -v which gave origin git#github.com:railstutorial/first_app.git. To change it, i typed: git config remote.origin.url git#github.com:tomkim310/first_app.git.
This then did the trick and git push origin master worked.
I'm new to rails and git. I have a rails application under ..../myapp that I would like to deploy using capistrano. I followed the steps described in "Agile Web Development with Rails". To put the application under version control, I did the following:
1) Put my application under version control:
$ cd myapp
$ git init
$ git add .
$ git commit "..."
That all went fine, it created a .git directory under myapp/
2) Created an empty repository on the server:
$ mkdir -p ~/git/myapp.git
$ cd ~/git/myapp.git
$ git --bare init
$ Initialized empty Git repository in /root/git/myapp.git/
3) Created a public key
$ ssh-keygen -t rsa -C "myemail#myemail.com"
$ Your identification has been saved in /root/.ssh/id_rsa.
$ Your public key has been saved in /root/.ssh/id_rsa.pub.
$ The key fingerprint is:
$ d2:16:76:e0:4c:71:de:de:4b:d3:16:94:cc:d7:65:11 myemail#myemail.com
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
4) From my application directory: created the path to the server and push the code
$ git remote add origin ssh://me#host/~/git/myapp.git
$ git push origin master
Now I'm being asked to enter my password, after that:
$ fatal: '~/git/myapp.git' does not appear to be a git repository
$ fatal: The remote end hung up unexpectedly
It might be worth noting that this all happens on the same server, a RHEL 5.7. This is something that confuses me because I basically ssh from my server onto my server. But apparently that's how capistrano does it, even if the application_development and the svn repository are on the same physical machine.
# manojlds:
$ GIT_TRACE=2 git push origin master
$ trace: built-in: git 'push' 'origin' 'master'
trace: run_command: 'ssh' 'me#host' 'git-receive-pack '\''/root/git/myapp.git'\'''
Pretty sure you don't want the tilde ~ in the path. I'd put the actual path in (eg /home/users/)
It is possible that using a relative path and specifying the ssh portion is causing it to break when adding origin.
Try something closer to this:
git remote add origin user#myserver.com:/var/git/myapp.git
Here a step of installation in heroku web hosting website:
Track your application with Git
If you’re already using Git with your application, skip to the next step. If you’re not yet using Git to track your application, run this:
$ cd PATH/TO/MY_APP
$ git init
Initialized empty Git repository in .git/
$ git add .
$ git commit -m "new app"
Created initial commit 5df2d09: new app
44 files changed, 8393 insertions(+), 0 deletions(-)
when I cd to the PATH/TO/MY_APP
there's no such dictionary, So I guess it's a custom path which should add to the user path file manually, Is that right?
It means path to your app, so if your app is in /usr/bin/myapp, than it is "/usr/bin/myapp".
I have created a brand new heroku app, beforehand i deleted the old .git file from my app's directory and created a new one with the usual steps:
git init, git add ., git commit -m "new git"
all of which worked fine. I then created a new app like so and got the following error:
$ heroku create
Creating glowing-summer-56.... done
Created http://glowing-summer-56.heroku.com/ | git#heroku.com:glowing-summer-56.
git
Git remote heroku added
$ git push heroku master
Counting objects: 1553, done.
Delta compression using up to 4 threads.
fatal: object 91f5d3ee9e2edcd42e961ed2eb254d5181cbc734 inconsistent object lengt
h (387 vs 8985)
error: pack-objects died with strange error
error: failed to push some refs to 'git#heroku.com:glowing-summer-56.git'
This is strange to me, as it is a brand new .git file. How can I get rid of this without cleaning up each damaged object? Is there a way to just delete the git file and start anew? I'm not using this git file for anything other than pushing to heroku.
Also I should note that I am using Cygwin on windows and my git version is 1.6.6.1
I've come across this error before and fixed it, I just honestly can't remember how.
Finally, using git fsck --full yields nothing :(
Thanks,
i seemingly fixed this with: git reset