github reference

For home projects, the most likely workflow is to first create the project in some computer, then modify it continuously until it becomes fit enough to publish. At this stage, we have a project in the local machine and we wish to upload it in a new repository on github.com.

For people coming from different version control systems, git offers some challenge as the terminology is different for same functions. The following steps will push local changes to a remote repository.

1. On github.com, create a new repository (empty) using the web interface, without specifying any README.md files. Note the URL for repository once created. Say for example, the URL is https://github.com/user/project-name.git for the repository ‘project-name’.

2. On the local machine, navigate to the project folder and run

$ git init

This will create a blank repository in the folder, whose details are stored in .git subfolder.

3. Now, create a readme file and add files of the project to the repository:

$ echo "# project-name" >> README.md
$ git add pom.xml src/ README.md

4. Add files to the local branch by running

$ git commit -m "initial commit message"

5. Hook up the local repository to the remote one (created on github.com)

$ git remote add origin https://github.com/user/project-name.git

where user is the username on git, and URL is the same as the one mentioned by git at the end of creating the repository in the first step.

6. Push the local changes to remote repository:

$ git push origin master

Now the local changes will be available on the remote repository to be used by others.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s