2013-01-04 141 views
0

我在我的工作区中有一个Java项目,我试图将其推送到GitHub。如何查看GitHub上的存储库

我是第一次使用Git用户,并没有创建GitHub帐户。

这些是我遵循的步骤。

  1. 从源代码文件夹

    最初,我确实:

    git --bare init

  2. 再次我跑git init命令:

    git init

  3. 创建远程仓库:

    git remote add origin ssh://ravi.kiran.com/home/sai/workspace/Sai

  4. 然后,我把我的本地文件版本控制之下。

    git add .

  5. git commit -a -m 'initialize repo'

  6. 然后我把我的全局配置:

    结果的git config -l

    git config --global user.email "[email protected]" git config --global user.name "ravikirantest"

  7. [email protected]:~/workspace/Sai/src$ git config -l 
    
    [email protected] 
    user.name=ravikirantest 
    
    core.repositoryformatversion=0 
    core.filemode=true 
    core.bare=false 
    core.logallrefupdates=true 
    
    remote.origin.url=ssh://ravi.kiran.com 
    remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* 
    

请告诉我如何在GitHub中查看我的存储库!

在此之后,我甚至创建了一个GitHub帐户,其中包含上述指定的 电子邮件和用户名,但我无法在github.com上查看我的文件。

更新部分

[email protected]:~/workspace/Sai/src$ git push origin master 

Username for 'https://github.com': ravikirantest 

Password for 'https://[email protected]': 

To https://github.com/ravikirantest/Chandrayan.git 

! [rejected]  master -> master (non-fast-forward) 

error: failed to push some refs to 'https://github.com/ravikirantest/Chandrayan.git' 

hint: Updates were rejected because the tip of your current branch is behind 

hint: its remote counterpart. Merge the remote changes (e.g. 'git pull') 

hint: before pushing again. 

hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

[email protected]:~/workspace/Sai/src$ 

回答

3

一旦你创建了GitHub上的帐户,您将能够创建从GitHub的Web界面新仓库。

一旦你创建了这个仓库,你会看到(在你的仓库页面的GitHub中详细说明)它的URI。然后,您可以将其设置为本地计算机的远程设备,然后将其推送到该设备。

你的本地计算机上的程序是如下:

git init 
git add . 
git commit -m "initial commit" 
git remote add origin https://github.com/[your account]/[your repository] 
git push origin master 

我想也许你的困惑的一部分是不承认作为一个版本控制系统Git的之间的差异,GitHub的是托管项目服务。 Git将完全独立于GitHub。或者您可以使用GitHub来托管您的核心存储库,如上所述。

+0

我知道你正在试图帮助我,我正在关注你的帖子,并试图做同样的事情,但我感到一个问题。 – Pawan

+0

如果这是您第一次推到新的GitHub仓库,我想知道您的初始尝试是否会让您感到困惑?即也许从一个干净的石板重新开始? – harunahi