Apache NetBeans 14

blue badge

Two Unnecessary Costs of Software Development

Putting my “Chief Technology Officer” hat on for a second, there are lots of cost levers behind the total expense of software development and most of them are necessities. Yes, we should always allow plenty of time and money for testing and user feedback. Yes, we should try to pay down technical debt. We’re not talking about any of that.

Private companies working on proprietary software can mitigate a small amount of this through standardizing development processes, but open source projects are a total free-for-all.

In the end, what’s needed in order to eliminate false starts and blind alleys is for individual developers themselves to practice using Github effectively in order to not waste their own time and effort working on the wrong thing. This guide will help show you how.

Initializing a Git Repository

initialize git repo small

Specify the path to the repository you are going to store your versioned files in the Initialize a Git Repository dialog box or click Browse and browse for the directory required.

A .git subfolder is created in the folder you specified in step 3 above (your NetBeans project folder by default), which is your Git repository where all the data of your project snapshots are stored. Git starts versioning all files in the folder you specified. You can open Window > Output > Output to view the IDE’s report about the progress of the repository creation under your local working directory.

output init

All the project files are marked Added in your Working Tree. To view a file status, place the cursor over the file name in the Projects window. The status of the file in the Working Tree displays in green to the right of the slash like shown in the following picture.

new locally

Cloning a Git Repository

clone wizard small

In the Parent Directory field, the path to the directory intended for the cloned repository on your hard drive (alternatively, click the Browse button and navigate to the directory). The Parent Directory field is pre-filled with the path to the default NetBeansProjects directory where all NetBeans projects are stored.

Leave the Scan for NetBeans Projects after Clone checkbox selected to activate after-scanning right after the clone finishes. (The plugin searches for NetBeans projects in the cloned resources and offers to open the found projects.)

Cloning a Repository from GitHub via SSH protocol

(Skip if using SSH-agent or Pageant for automated SSH access to the Git server.) Complete the following steps to access the Git server using your private SSH key and a passphrase:

Specify the path to the key file, for example C:\Users\key . The OpenSSH private key format is required. Keys generated by PuTTYgen for Microsoft Windows must be converted to the OpenSSH format before using them in the IDE.

(Applies if using SSH-agent or Pageant for automated SSH access to the Git server.) Leave the Private Key File and Passphrase fields empty to get authenticated access from the IDE to the Git server via correctly configured SSH-agent or Pageant.

github repo small

github branches small

In the Parent Directory field, the path to the directory intended for the cloned repository on your hard drive (alternatively, click the Browse button and navigate to the directory). The Parent Directory field is pre-filled with the path to the default NetBeansProjects directory where all NetBeans projects are stored.

Leave the Scan for NetBeans Projects after Clone checkbox selected to activate after-scanning right after the clone finishes. (The plugin searches for NetBeans projects in the cloned resources and offers to open the found projects.)

github destination small

clone completed

Adding Files to a Git Repository

When adding files to a Git repository, the IDE composes and saves snapshots of your project first in the Index. After you perform the commit, the IDE saves those snapshots in the HEAD. The IDE allows you to choose between the two workflows described in the following table.

changes head index

[start=4] . In the Commit dialog box, select the Changes between HEAD and Index ( ) toggle button. This displays the list of files that are already staged.

changes head wt

[start=3] . In the Commit dialog box, select the Select the Changes between HEAD and Working Tree ( ) toggle button. This displays the list of files that are not staged.

new

Step Four: Create Your First Repository

Now that you’ve made it this far, you can actually use GitHub! As a first order of business, we’re going to create a repository (or “repo” for short). Head on over to GitHub and click the “New Repository” button on the top right of your account page. (Note: If you’re still displaying the GitHub bootcamp section, it’ll show up underneath it.)

When creating a repository you have a few things to decide including it’s name and whether it’ll be publicly accessible or not. Choosing a name should be pretty simple because you likely already have a name for your project. If you’re just following along for learning purposes, use “Hello-World.” Why “Hello-World” and not “Hello World”? Because spaces and special characters will cause problems. Keep it simple and easy to type in the command line. If you want to include a more complex name, you can add it to the optional description field beneath the name field.

If you’re creating an open-source project, you want a public repository. If you want to code by yourself or share only with specific people, a private repository will do. Make the choice that works best for you and your project.

When you’re all done, you can click the “Create repository” button but you might want to do one other thing first: check the “Initialize this repository with a README” checkbox. Why? All repositories require a README file. Ideally that file would contain a little information about your project, but you might not want to deal with that right now. By initializing the repository with a README, you’ll get an empty README file that you can just deal with later. For the purposes of this tutorial, we’re going to leave the box unchecked because, in the next section, we’re going to create a README file from scratch to practice committing (sending) it to GitHub.

Step Five: Make Your First Commit

When you send files to GitHub, you commit them. To practice, we’re going to initialize your local repository and create a README file to commit as practice. Before you start, you need to know where your local code repository is on your computer and how to access it via the command line. In this tutorial, we’re going to assume there’s a directory called “Hello-World” in your computer’s home folder. If you need to create one, just run this command (same for Git Bash on Windows and OS X’s terminal):

In case you were wondering, the ~ represents your home directory in Git Bash and Terminal. It’s simply shorthand so you don’t have to type it all out (which would look more like /Users/yourusername/). Now that your repository is ready, type this:

If you already had a repository ready to go, you’d just need to cd to that directory and then run the git init command in there instead. Either way, your local repository is ready to go and you can start committing code. But wait, you don’t have anything to commit! Run this command to create a README file:

Let’s take a break for a second and see what just happened. Go into the home folder on your computer and look at the Hello-World folder (or look at whatever folder you’re using for a local repository). You’ll notice a README file inside, thanks to the command you just ran. What you won’t see is a .git folder, but that’s because it’s invisible. Git hides it in there, but because you ran the git init command you know it exists. If you’re skeptical, just run the ls command in Git Bash/Terminal to display a list of everything in the current directory (which, if you’re following along, is your local repository).

While the other commands were pretty straightforward, the commit command has a little more going on so let’s break it down. When you type git , that’s just telling the command line that you want to use the git program. When you type commit , you’re telling git you want to use the commit command. Everything that follows those two thing count as options. The first, -m, is what’s known as a flag. A flag specifies that you want to do something special rather than just run the commit command. In this case, the -m flag means “message” and what follows it is your commit message (in the example, ‘first commit’). The message isn’t absolutely necessary (although you’ll usually need to provide one), but simply a reference to help you differentiate the various versions of a file (or files) you commit to your repository.

Your first commit should go by in a split second because you haven’t actually uploaded anything yet. To get this empty README file to GitHub, you need to push it with a couple of commands. Here’s the first:

Source:

https://petabridge.com/blog/use-github-professionally/
https://netbeans.apache.org/kb/docs/ide/git.html
https://lifehacker.com/how-the-heck-do-i-use-github-5983680

Leave a Reply

Your email address will not be published. Required fields are marked *