Showing posts with label Github. Show all posts
Showing posts with label Github. Show all posts

Git - Using Multiple Repositories Simultaneously

You can use github and gitorious for the code hosting and for version control at the same time. I have found that there doesn't require much effort to do while pushing the code at the same time while using github and gitorious.

Here's what i do.

1. Install git on machine . In my case it is linux.
2. Sign up and create repositories on github and gitorious.
3. Add remote repositories with different names for both repos.
4. Commit and push.

Follow this workflow if you want.

git init
touch README.md
git remote add origin http://github.com/var/git/myapp.git
git remote add hosted http://gitorious.com/var/git/myapp.git
git add .
git commit -m "update"
git push origin master
git push hosted master


That's it. You are now pushing and hosting the code on two different repositories. You can add more repositories with different names into this and follow the same steps.

error: src refspec master does not match any github git commit error

I got this error when I was trying to push the changes to the remote server. It says the following on the command line where you can see how that error is going on.

error: src refspec master does not match any.
error: failed to push some refs to 'ssh://xxxxx.com/project.git'

This means you are missing the commit on local branch first. You should do that and then proceed with the remote commit.

Follow the steps like this while doing the git workflow.

git init
touch README.md
git commit -m "update"
git remote add origin /path/to/origin.git
git add .
git commit -m 'second update'
git push origin master


That's it. It's the commit that you need to do before pushing. If you do the commit first as show in the steps, you will see that it works just fine.

Github Error fatal: did you run git update-server-info on the server?

I downloaded the genesis-sample-theme from studiopress website and it had .svn and other folder hidden pointed to the alternate repository URL. This prompted error while i was trying to commit the new child theme on github.

In most of the cases the solution posted here should solve your problem. If not, feel free to ask to github help support.

Error was:

fatal: https://github.com/briangardener/genesis-sample.git/info/refs not found:
did you run git update-server-info on the server?

As the repository was deleted yet the .svn folder in the child theme was holding the remote url to that location. We are going to change that now.

And I did the following steps to clear the errors.

First step, use remote feature of git. Read more about remote.

git remote -v

It should return something like this;

origin    git@github.com:github/git-reference.git (fetch)
origin    git@github.com:github/git-reference.git (push)

Now add the new origin that applies to your github repository, it should be SSH path of the repository.

git remote add github git@github.com:schacon/hw.git

do run the remote command again

git remote -v

github    git@github.com:new/hw.git (fetch)
github    git@github.com:new/hw.git (push)

That's it. Now the fatal error should be gone when the next time you try to commit and push.

More solutions for this problem, try any one of the following that applies to you.

  • It also happens if the repository is deleted by you. So create again, so that github can refer to it.
  • When you download from the github, make sure you use git remote add for the new reference that points to your repository.
  • Check the case sensitive names.
  • Make sure the repository is not private and if private consult with github help docs on how to resolve this.
  • If you are collaborator, ask to be added in the repository collaborators list.

Git Error rejected master -> master (non-fast-forward)

I got error from the git while committing the changes using push - u origin master

! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:mahesh/childtheme.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.


I copied the files in the directory into another temp directory. And then ran the following command.

git pull --rebase

Then I tried to reset the git using.

git --reset hard origin/master

or

git clean -d -x -n

This cleared the git content on the local directory.  I pulled the git content from the github repository to see if it syncs properly.

git push

This synced the git local content with the githhub remote content. Then copied the temporary files content which i saved earlier into the local directory where i was running git. And then committed the changes.

git commit

It worked for two reasons. I cleared the git and also rebased it as well. Then the properly using the push on remote server, it synced just fine.