Adding a project to GitHub – things to watch out

Not having much experience with Git, I made a watch out list, so I can refer back later without making a same mistake.

1. Do not add README.md when I create a new repository in GitHub. By adding README.md seems giving me a trouble later on.
2. Know the difference between git add -A vs. git add . (dot) vs. git add -u. Here is the difference.

  • git add -A stages All
  • git add . stages new and modified, without deleted
  • git add -u stages modified and deleted, without new

Below is the Git commands for my reference in the future.

msjo@MSJO-PC ~
$ cd gitrepo

msjo@MSJO-PC ~/gitrepo
$ ls
WebSocketJEE7Demo  WebsocketDemo

msjo@MSJO-PC ~/gitrepo
$ cd websocketjee7demo

msjo@MSJO-PC ~/gitrepo/websocketjee7demo
$ ls
WebSocketJEE7Demo

msjo@MSJO-PC ~/gitrepo/websocketjee7demo
$ touch README.md

msjo@MSJO-PC ~/gitrepo/websocketjee7demo
$ git init
Initialized empty Git repository in c:/Users/msjo/gitrepo/websocketjee7demo/.git
/

msjo@MSJO-PC ~/gitrepo/websocketjee7demo (master)
$ touch README.md

msjo@MSJO-PC ~/gitrepo/websocketjee7demo (master)
$ git add README.md

msjo@MSJO-PC ~/gitrepo/websocketjee7demo (master)
$ git commit -m "first commit"
[master (root-commit) 4e202d8] first commit
 0 files changed
 create mode 100644 README.md

msjo@MSJO-PC ~/gitrepo/websocketjee7demo (master)
$ git add websocketjee7demo

msjo@MSJO-PC ~/gitrepo/websocketjee7demo (master)
$ git status
# On branch master
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
#       WebSocketJEE7Demo/
nothing added to commit but untracked files present (use "git add" to track)

msjo@MSJO-PC ~/gitrepo/websocketjee7demo (master)
$ git add -A
warning: LF will be replaced by CRLF in WebSocketJEE7Demo/WebContent/WEB-INF/fac
es-config.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in WebSocketJEE7Demo/WebContent/WEB-INF/gla
ssfish-web.xml.
The file will have its original line endings in your working directory.

msjo@MSJO-PC ~/gitrepo/websocketjee7demo (master)
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD ..." to unstage)
#
#       new file:   WebSocketJEE7Demo/.classpath
#       new file:   WebSocketJEE7Demo/.project
#       new file:   WebSocketJEE7Demo/.settings/.jsdtscope
#       new file:   WebSocketJEE7Demo/.settings/org.eclipse.jdt.core.prefs
#       new file:   WebSocketJEE7Demo/.settings/org.eclipse.wst.common.component

#       new file:   WebSocketJEE7Demo/.settings/org.eclipse.wst.common.project.f
acet.core.prefs.xml
#       new file:   WebSocketJEE7Demo/.settings/org.eclipse.wst.common.project.f
acet.core.xml
#       new file:   WebSocketJEE7Demo/.settings/org.eclipse.wst.jsdt.ui.superTyp
e.container
#       new file:   WebSocketJEE7Demo/.settings/org.eclipse.wst.jsdt.ui.superTyp
e.name
#       new file:   WebSocketJEE7Demo/WebContent/META-INF/MANIFEST.MF
#       new file:   WebSocketJEE7Demo/WebContent/WEB-INF/faces-config.xml
#       new file:   WebSocketJEE7Demo/WebContent/WEB-INF/glassfish-web.xml
#       new file:   WebSocketJEE7Demo/WebContent/WEB-INF/web.xml
#       new file:   WebSocketJEE7Demo/WebContent/chatWindow.xhtml
#       new file:   WebSocketJEE7Demo/WebContent/js/jquery-2.0.2.min.js
#       new file:   WebSocketJEE7Demo/build/classes/endpoint/MyServerEndpoint.cl
ass
#       new file:   WebSocketJEE7Demo/src/endpoint/MyServerEndpoint.java
#

msjo@MSJO-PC ~/gitrepo/websocketjee7demo (master)
$ git commit -m 'another commit'
[master 385faa3] another commit
warning: LF will be replaced by CRLF in WebSocketJEE7Demo/WebContent/WEB-INF/fac
es-config.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in WebSocketJEE7Demo/WebContent/WEB-INF/gla
ssfish-web.xml.
The file will have its original line endings in your working directory.
 17 files changed, 320 insertions(+)
 create mode 100644 WebSocketJEE7Demo/.classpath
 create mode 100644 WebSocketJEE7Demo/.project
 create mode 100644 WebSocketJEE7Demo/.settings/.jsdtscope
 create mode 100644 WebSocketJEE7Demo/.settings/org.eclipse.jdt.core.prefs
 create mode 100644 WebSocketJEE7Demo/.settings/org.eclipse.wst.common.component

 create mode 100644 WebSocketJEE7Demo/.settings/org.eclipse.wst.common.project.f
acet.core.prefs.xml
 create mode 100644 WebSocketJEE7Demo/.settings/org.eclipse.wst.common.project.f
acet.core.xml
 create mode 100644 WebSocketJEE7Demo/.settings/org.eclipse.wst.jsdt.ui.superTyp
e.container
 create mode 100644 WebSocketJEE7Demo/.settings/org.eclipse.wst.jsdt.ui.superTyp
e.name
 create mode 100644 WebSocketJEE7Demo/WebContent/META-INF/MANIFEST.MF
 create mode 100644 WebSocketJEE7Demo/WebContent/WEB-INF/faces-config.xml
 create mode 100644 WebSocketJEE7Demo/WebContent/WEB-INF/glassfish-web.xml
 create mode 100644 WebSocketJEE7Demo/WebContent/WEB-INF/web.xml
 create mode 100644 WebSocketJEE7Demo/WebContent/chatWindow.xhtml
 create mode 100644 WebSocketJEE7Demo/WebContent/js/jquery-2.0.2.min.js
 create mode 100644 WebSocketJEE7Demo/build/classes/endpoint/MyServerEndpoint.cl
ass
 create mode 100644 WebSocketJEE7Demo/src/endpoint/MyServerEndpoint.java

msjo@MSJO-PC ~/gitrepo/websocketjee7demo (master)
$ git remote add origin https://github.com/mjtoolbox/WebSocketJEE7.git

msjo@MSJO-PC ~/gitrepo/websocketjee7demo (master)
$ git push origin master
usage: git credential-cache [options]

    --exit                tell a running daemon to exit
    --reject              reject a cached credential
    --timeout          number of seconds to cache credentials
    --socket        path of cache-daemon socket
    --chain       use  to get non-cached credentials
    --username      an existing username
    --description   human-readable description of the credential
    --unique       a unique context for the credential

Username for 'https://github.com':
Password for 'https://mjtoolbox@github.com':
usage: git credential-cache [options]

    --exit                tell a running daemon to exit
    --reject              reject a cached credential
    --timeout          number of seconds to cache credentials
    --socket        path of cache-daemon socket
    --chain       use  to get non-cached credentials
    --username      an existing username
    --description   human-readable description of the credential
    --unique       a unique context for the credential

To https://github.com/mjtoolbox/WebSocketJEE7.git
 * [new branch]      master -> master

msjo@MSJO-PC ~/gitrepo/websocketjee7demo (master)
$

Conclusion

I can try to use UI tool to make it easier, but I feel that using Git command will enhance my experience in a long run.

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