Have started working on another experimental project. This project is specifically for my learning purpose. I’m trying to automate few of my regular tasks. The same way I resolved earlier Reminder service or Automatically send emails using filters or Auto login to internet portal etc. Would like to tag these as ‘food for thought’. Will come back to new project details in a few months. This time I’m thinking in some broader aspect. To initiate that, the very first step is to set up its configuration properly. That is the reason behind this post.
$ sudo apt-get update
$ sudo apt-get install git
That’s pretty straightforward. Useful details on github-ssh connectivity is here.
Create local repository
$ cd java-setup/
$ ls -lt
drwxrwxr-x 2 kuntal kuntal 4096 Jan 2 14:31 bin
drwxrwxr-x 2 kuntal kuntal 4096 Jan 2 14:31 src
$ git init
Initialized empty Git repository in /var/www/java-setup/.git/
$ git config --global user.name "kuntalchandra"
$ git config --global user.email email@example.com
Created the gitignore file
$ cat .gitignore
*~ .classpath .project *.class # Mobile Tools for Java (J2ME) .mtj.tmp/ # Package Files # *.jar *.war *.ear # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid*
Git will read this file and skip the files and folders I listed there. This is necessary when we work with temp or personal files that we don’t want to commit in the repository.
Created the readme file from template
$ cat README.md
## Synopsis At the top of the file there should be a short introduction and/ or overview that explains **what** the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.) ## Code Example Show what the library does as concisely as possible, developers should be able to figure out **how** your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise. ## Motivation A short description of the motivation behind the creation and maintenance of the project. This should explain **why** the project exists. ## Installation Provide code examples and explanations of how to get the project. ## API Reference Depending on the size of the project, if it is small and simple enough the reference docs can be added to the README. For medium size to larger projects it is important to at least provide a link to where the API reference docs live. ## Tests Describe and show how to run the tests with code examples. ## Contributors Let people know how they can dive into the project, include important links to things like issue trackers, irc, twitter accounts if applicable. ## License A short snippet describing the license (MIT, Apache, etc.)
$ git status
On branch master
(use "git add ..." to include in what will be committed)
nothing added to commit but untracked files present (use “git add” to track)
$ git add --all
$ git commit -m "Initial commit"
[master (root-commit) 34a8ff3] Initial commit
4 files changed, 70 insertions(+)
create mode 100644 .gitignore
create mode 100644 README.md
create mode 100644 src/ListAllDir.java
create mode 100644 src/Ugly.java
Local git repository has been configured.
Create the remote repository
A remote repository is actually a central repository where others can push their changes to it. It’s nothing other than the remote copy of the same Git repository created locally.
$ ls -lta
drwxrwxr-x 8 kuntal kuntal 4096 Jan 2 15:04 .git
drwxrwxr-x 5 kuntal kuntal 4096 Jan 2 15:00 .
-rw-rw-r-- 1 kuntal kuntal 212 Jan 2 15:00 .gitignore
-rw-rw-r-- 1 kuntal kuntal 1300 Jan 2 14:59 README.md
drwxrwxr-x 2 kuntal kuntal 4096 Jan 2 14:57 src
drwxrwxr-x 2 kuntal kuntal 4096 Jan 2 14:56 bin
-rw-rw-r-- 1 kuntal kuntal 226 Jan 2 14:56 .classpath
-rw-rw-r-- 1 kuntal kuntal 368 Jan 2 14:56 .project
drwxrwxrwx 4 kuntal kuntal 4096 Jan 2 14:56 ..
$ git remote add origin firstname.lastname@example.org:kuntalchandra/java-setup.git
$ git push -u origin master
As the repository is public, so protect code from force push to master branch