Jump to content

Git-bash assistance

Sdot

Hello, I have completed a java assignment using netbeans. there is an additional step that I do not know how to complete.

My assignment is to create a git-hub account, which I did already.

Next I have to add my project to git bash, use gitignore to ignore all of the files they are not needed, upload a repository, etc.

Is anyone familiar with this progam and are you willing to help me?

Link to comment
Share on other sites

Link to post
Share on other sites

I found the GitHub help pretty easy to understand and very helpful when I first started using git: https://help.github.com/

Crystal: CPU: i7 7700K | Motherboard: Asus ROG Strix Z270F | RAM: GSkill 16 GB@3200MHz | GPU: Nvidia GTX 1080 Ti FE | Case: Corsair Crystal 570X (black) | PSU: EVGA Supernova G2 1000W | Monitor: Asus VG248QE 24"

Laptop: Dell XPS 13 9370 | CPU: i5 10510U | RAM: 16 GB

Server: CPU: i5 4690k | RAM: 16 GB | Case: Corsair Graphite 760T White | Storage: 19 TB

Link to comment
Share on other sites

Link to post
Share on other sites

looking through it now, some things I get, other things I don't :(

Link to comment
Share on other sites

Link to post
Share on other sites

For the .gitignore part, you need to create a file in the root of your repository titled ".gitignore" (with nothing before the ., I don't remember how to do this on Windows), then in that file you can put the name or path of the file to ignore on each line. The full docs are here, but a sample file might look something like

*.tmp
/path/from/git/directory/to/my.file
/directory/

 

On your GitHub account, you need to create a repo. Once you've created that, it should have instructions for adding an existing project to that repo. The commands will look something like

git init
git add -A
git commit -m "Initial commit"
git remote add origin git@github.com:/yourusername/yourrepo
git push --set-upstream origin master

In order, those commands initialise a new repository, mark all the files as "to commit", commit the files (effectively save a snapshot of them), connect it to github, then sync with github.

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

43 minutes ago, colonel_mortis said:

For the .gitignore part, you need to create a file in the root of your repository titled ".gitignore" (with nothing before the ., I don't remember how to do this on Windows), then in that file you can put the name or path of the file to ignore on each line. The full docs are here, but a sample file might look something like


*.tmp
/path/from/git/directory/to/my.file
/directory/

 

On your GitHub account, you need to create a repo. Once you've created that, it should have instructions for adding an existing project to that repo. The commands will look something like


git init
git add -A
git commit -m "Initial commit"
git remote add origin git@github.com:/yourusername/yourrepo
git push --set-upstream origin master

In order, those commands initialise a new repository, mark all the files as "to commit", commit the files (effectively save a snapshot of them), connect it to github, then sync with github.

awesome, I'll follow those. Do you know where I apply the Git Bash? Documents/SimUniversity/

Do I just git bash the Sim University folder or do I go into the folder that contains my java files?

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Sdot said:

awesome, I'll follow those. Do you know where I apply the Git Bash? Documents/SimUniversity/

Do I just git bash the Sim University folder or do I go into the folder that contains my java files?

If your java files are in Documents/SimUniversity/src/name/space/file.java, you would typically initialise the git repository in Documents/SimUniversity.

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

 22196255_10209239327291166_7890595632849

So far so good, I just have to figure out this git ignore thing. It says create a text file named .gitignore in the repository, So I just that (after I took the picture). How do I make it ignore everything except for the java files?

Link to comment
Share on other sites

Link to post
Share on other sites

21 minutes ago, Sdot said:

 

So far so good, I just have to figure out this git ignore thing. It says create a text file named .gitignore in the repository, So I just that (after I took the picture). How do I make it ignore everything except for the java files?

You probably want a .gitignore that looks something like

build/
nbproject/
*.xml

However, it won't take effect because you have already run git add. To undo that, run

git reset

then you can check which files it will add by running

git status

If you're happy that it's only including java files, you can then run git add -A, but if there are other files that you don't want then you'll need to add some more rules to the gitignore file first. After adding rules to the .gitignore file and saving it, you can run git status again to check again.

 

I don't think Windows will let you make a file that starts with . though, so you'll need to look up how to do that (it might be possible from the command line).

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

sorry, the instructions are " Use the .gitignore file to instruct git to ignore the files that are generated by the Java compiler and the settings that your IDE uses." How would I go about doing that?

 

These are the instructions. I think after I get the ignore thing working I am good to finish.!

 

Use the .gitignore file to instruct git to ignore the files that are generated by the Java compiler and the settings that your IDE uses.

Create a github account. Do not use a silly/funny name. Think of this as something that will be part of your resume.

Create a public project and push the repo to github.

Submit your github repo URL. It should be https://github.com/[your_github_account]/[your_project_name] by the deadline.

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Sdot said:

sorry, the instructions are " Use the .gitignore file to instruct git to ignore the files that are generated by the Java compiler and the settings that your IDE uses." How would I go about doing that?

 

These are the instructions. I think after I get the ignore thing working I am good to finish.!

 

Use the .gitignore file to instruct git to ignore the files that are generated by the Java compiler and the settings that your IDE uses.

Create a github account. Do not use a silly/funny name. Think of this as something that will be part of your resume.

Create a public project and push the repo to github.

Submit your github repo URL. It should be https://github.com/[your_github_account]/[your_project_name] by the deadline.

You need to create a file called ".gitignore" (no quotes) in your project directory (the same directory that the .git folder is in), then open that file in a text editor (such as notepad) and enter the contents that I suggested in the previous post (and save). Based on the instructions though, it sounds like the .xml files are probably wanted, so you may not want to include the "*.xml" line.

On Windows, apparently to create the .gitignore file the easiest way is to open notepad, enter all the contents, then save it as gitignore.txt. You should then use the file browser to rename it to ".gitignore." (note trailing ., which will be automatically trimmed when the rename is actually performed when you press enter). I've not tested this though, so if it doesn't work you may need to look up how to do it.

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

alrighty, I have build/ and nbproject/ inside of the text document named .gitignore which is inside the .git repository.

 

I used git add src. because when I use git status, it still includes the build/ and nbproject/ folders.

I think I'm just going to go with this and work on trying to add it to my github.com now.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×