镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Cant push to github #346

Closed
Closed

Description

@jwaldrip

I cannot push to a github repo. What am I doing wrong?

repo = Rugged::Repository.init_at('./data')
File.open('./data/sample', 'w+'){ |f| f.write 'sample data' }
repo.index.add('./data/sample')

 # Build the commit
author  = { email: "jason@waldrip.net", name: 'Jason Waldrip', time: Time.now }
options = {
  tree:       index.write_tree(repo),
  author:     author,
  committer:  author,
  message:    'Added ' + peak.name,
  parents:    repo.empty? ? [] : [repo.head.target].compact,
  update_ref: 'HEAD'
}

# Commit!
Rugged::Commit.create(repo, options)
remote = Rugged::Remote.lookup(repo, 'origin') ||
  Rugged::Remote.add(repo, 'origin', 'git@github.com:jwaldrip/push-sample.git')

# Push
ref = 'refs/heads/master'
remote.push([ref])

Rugged::Error: could not push to repo (check for non-bare repo)

Activity

  1. carlosmn commented on Apr 4, 2014

    @carlosmn
    Member

    That piece of code does not contain any pushing. We cannot know unless you show what you're doing to perform the push.

    But guessing, the most likely reason is that you're not providing credentials.

  2. jwaldrip commented on Apr 4, 2014

    @jwaldrip
    Author

    How do you provide the credentials? And i'm sorry, I forgot to add the commit.

  3. arthurschreiber commented on Apr 4, 2014

    @arthurschreiber
    Member

    The code to support pushing with credentials has not landed yet in Rugged. You can check out an initial draft in #304, but I'm currently really unhappy with it and plan on completely changing the implementation and semantics.

    You probably can use what is implemented there, but you have to understand that you'll need to update your code as soon as I land an updated version of it in Rugged.

  4. arthurschreiber commented on May 21, 2014

    @arthurschreiber
    Member

    #304 was merged and contained the changes to support pushing to a remote with credentials.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions