-1

Im relativity new to coding and have never used any kind of version control software.

Id like to use git hub to store all the practice code im writing so i can keep a record of the changes i make.

I have successfully created an few repos in git hub however when i try to store my code it displays in plain text read me format like this:

https://github.com/600rob/New-Java/blob/master/README.md

Note, im using the git hub website only and do not have GIT software installed don my machine due to it be and work machine with install restrictions

Can anyone tell me how i can set up a repo and get my code to display in code format like this:

https://github.com/eviltester/javaForTestersCode/blob/master/source/src/main/java/com/javafortesters/domainentities/AdminUser.java

do i need to have the Git software installed on my machine as opposed to just using the git hub site in order for this to be possible?

Thanks

rob

bobe_b
  • 187
  • 1
  • 2
  • 21
  • change name of the file from `README.md` to `Examples.java`. You can do it directly in github UI interface: https://github.com/600rob/New-Java/edit/master/README.md – jakub.g Mar 01 '17 at 15:42

2 Answers2

0

If you put all the code in the ReadMe.md it will always be displayed there. What you need is to go inside a new directory and run git init. Then you need to associate it with a GitHub repo and then just git add your code files and git commit -m "your changes" to make your commit. Then you run git push origin master and voila! This is a basic setup, later on you'll need to work with branches and more git stuff, so keep on learning.

Don't put everything into one file like you did now, the ReadMe file should contain information about what your code does and how to use it, not your code. You can do all of this through the GitHub website but it's far more convenient to do it with git. If you're on linux, chances are you have git already on your system, if you're on windows you need to download it.

Community
  • 1
  • 1
Kostas Andrianos
  • 1,551
  • 2
  • 16
  • 21
0

You have added your code in README.md file that will always display text. You should save it as Example.java and then upload it.

It will be better for you in future if you use Git Shell and GitHub application on your machine.

Git commands are simple: Once you create repository,

echo "# Repository_Name" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/user_name/Repository_Name.git
git push -u origin master

Then you can directly upload/drag-drop your code using upload files option.