I have a Java project in my workspace, which I am trying to push to GitHub.
I am a first-time Git user and didn’t create a GitHub account yet.
These are the steps I followed.
-
Initially from the source code folder, I did:
git --bare init -
Again I ran the
git initcommand:git init -
Created a remote repository:
git remote add origin ssh://ravi.kiran.com/home/sai/workspace/Sai -
Then, I place my local files under version control.
git add . -
git commit -a -m 'initialize repo' -
Then I set my global configurations:
git config --global user.email "ravitest@gmail.com"
git config --global user.name "ravikirantest" -
Result of
git config -l:sai@ravikiran:~/workspace/Sai/src$ git config -l user.email=ravitest@gmail.com 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/*
Please tell me how can I view my repository in GitHub!
After this, I even created a GitHub account with the above specified
email and username, but I am not able to view my files on github.com.
Updated Part
sai@ravikiran:~/workspace/Sai/src$ git push origin master
Username for 'https://github.com': ravikirantest
Password for 'https://ravikirantest@github.com':
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.
sai@ravikiran:~/workspace/Sai/src$
Once you have created your account on GitHub, you will be able to create a new repository from the GitHub web interface.
Once you have created this repository, you will see (detailed in GitHub on your repository page) the URI for it. You can then set this as a remote from your local machine and then push to it.
The procedure on your local machine would be as follows:
I think perhaps part of your confusion is not recognizing the difference between Git as a version control system and GitHub which is a service for hosting projects. Git will work completely independently of GitHub. Or you can use GitHub to host your core repository as described above.