Monday, January 19, 2015

How to create tag using git?

After pushing, you can make a tag.

rizvi@rizvi-pc:~/workspace/JavaRat1/src/org/rizvi$ git push origin br1001:br1001
Username for 'https://github.com': macPro
Password for 'https://macPro@github.com':
To https://github.com/macPro/JavaRat1.git
0f480f9..6242663 br1001 -> br1001
rizvi@rizvi-pc:~/workspace/JavaRat1/src/org/rizvi$ git tag -a v1.0 -m 'my version 1.0'
rizvi@rizvi-pc:~/workspace/JavaRat1/src/org/rizvi$ git branch -a
* br1001
master
remotes/origin/br1001
remotes/origin/master
rizvi@rizvi-pc:~/workspace/JavaRat1/src/org/rizvi$ git tag
v1.0
rizvi@rizvi-pc:~/workspace/JavaRat1/src/org/rizvi$ git show v1.0
tag v1.0
Tagger: rizvi <rizvi@oriongroup.com>
Date: Mon Jan 19 16:33:12 2015 +0600
my version 1.0
commit 6242663b132c41e9714356de10cca880d113df9c
Author: rizvi <rizvi@oriongroup.com>
Date: Mon Jan 19 15:55:42 2015 +0600
"Orange.java is created"
diff --git a/src/org/rizvi/Orange.java b/src/org/rizvi/Orange.java
new file mode 100644
index 0000000..3f774cd
--- /dev/null
+++ b/src/org/rizvi/Orange.java
@@ -0,0 +1,10 @@
+package org.rizvi;
+
+public class Orange {
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ System.out.println("This is Orange class");
+ }
+
+}
rizvi@rizvi-pc:~/workspace/JavaRat1/src/org/rizvi$ git push origin v1.0
Username for 'https://github.com': macPro
Password for 'https://macPro@github.com':
To https://github.com/macPro/JavaRat1.git

* [new tag] v1.0 -> v1.0 

Make a sync with eclipse project and Github

First create a repo in github. Name will be like "BuilderPattern"

rizvi@rizvi-HP:~/workspace/BuilderPattern$ git init
Initialized empty Git repository in /home/rizvi/workspace/BuilderPattern/.git/

rizvi@rizvi-HP:~/workspace/BuilderPattern$ git remote add origin 
https://github.com/rizvi/BuilderPattern.git

rizvi@rizvi-HP:~/workspace/BuilderPattern$ ls
rizvi@rizvi-HP:~/workspace/BuilderPattern$ ls -lah
total 12K
drwxrwxr-x  3 rizvi rizvi 4.0K জুল    13 16:41 .
drwxrwxr-x 51 rizvi rizvi 4.0K জুল    13 16:19 ..
drwxrwxr-x  7 rizvi rizvi 4.0K জুল    13 16:43 .git

rizvi@rizvi-HP:~/workspace/BuilderPattern$ git fetch origin master
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/rizvi/BuilderPattern
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master

rizvi@rizvi-HP:~/workspace/BuilderPattern$ git branch -a
  remotes/origin/master

rizvi@rizvi-HP:~/workspace/BuilderPattern$ git checkout -b br#20170713 origin/master
Branch br#20170713 set up to track remote branch master from origin.
Switched to a new branch 'br#20170713'

rizvi@rizvi-HP:~/workspace/BuilderPattern$ git gui 
// Write a commit message and commit here.

rizvi@rizvi-HP:~/workspace/BuilderPattern$ git branch -a
* br#20170713
  remotes/origin/master

rizvi@rizvi-HP:~/workspace/BuilderPattern$ git push origin br#20170713:br#20170713
Username for 'https://github.com': rizvi
Password for 'https://rizvi@github.com': 
Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (14/14), 2.65 KiB | 0 bytes/s, done.
Total 14 (delta 0), reused 0 (delta 0)
To https://github.com/rizvi/BuilderPattern.git

 * [new branch]      br#20170713 -> br#20170713



In Github make a repository named by “JavaPro1

Make a Java Project in eclipse. Name is “JavaPro1”. Then open the command prompt and go to the location of the project of eclipse workspace.

rizvi@rizvi-pc:~/workspace/JavaPro1$ git init
Initialized empty Git repository in /home/rizvi/workspace/JavaPro1/.git/
rizvi@rizvi-pc:~/workspace/JavaPro1$ git add .
rizvi@rizvi-pc:~/workspace/JavaPro1$ git gui
rizvi@rizvi-pc:~/workspace/JavaPro1$ git remote add origin https://github.com/rizvi/JavaPro1.git
rizvi@rizvi-pc:~/workspace/JavaPro1$ git push -u origin master
Username for 'https://github.com': macPro
Password for 'https://macPro@github.com':
To https://github.com/macPro/JavaPro1.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.


rizvi@rizvi-pc:~/workspace/JavaPro1$ git branch -a
* master
remotes/origin/master
rizvi@rizvi-pc:~/workspace/JavaPro1$ git checkout -b br1001
Switched to a new branch 'br1001'
rizvi@rizvi-pc:~/workspace/JavaPro1$ cd src
rizvi@rizvi-pc:~/workspace/JavaPro1/src$ cd org/rizvi/
rizvi@rizvi-pc:~/workspace/JavaPro1/src/org/rizvi$ ls
Test.java
rizvi@rizvi-pc:~/workspace/JavaPro1/src/org/rizvi$ touch Test2.java
rizvi@rizvi-pc:~/workspace/JavaPro1/src/org/rizvi$ gedit Test2.java
rizvi@rizvi-pc:~/workspace/JavaPro1/src/org/rizvi$ git gui
rizvi@rizvi-pc:~/workspace/JavaPro1/src/org/rizvi$ git push origin br1001:br1001
Username for 'https://github.com': macPro
Password for 'https://macPro@github.com':
To https://github.com/macPro/JavaPro1.git

Monday, January 5, 2015

Ubuntu Special Command

ls: command options

Option      Action


-a list hidden files -d list the name of the current directory -F show directories with a trailing '/' executable files with a trailing '*' -g show group ownership of file in long listing -i print the inode number of each file -l long listing giving details about files and directories -R list all subdirectories encountered -t sort by time modified instead of name 
 
Example:
 
git@rizvi-pc:~$ ls -a -l
total 36
drwxr-xr-x 3 git  git  4096 Jan  5 16:31 .
drwxr-xr-x 4 root root 4096 Jan  5 16:27 ..
-rw-r--r-- 1 git  git   220 Jan  5 16:27 .bash_logout
-rw-r--r-- 1 git  git  3486 Jan  5 16:27 .bashrc
-rw-r--r-- 1 git  git  8445 Jan  5 16:27 examples.desktop
-rw-r--r-- 1 git  git   675 Jan  5 16:27 .profile
drwxrwxr-x 2 git  git  4096 Jan  5 16:31 .rizvissh
 

Ubuntu User: A command to list all users? And how to add, delete, modify users?

A command to list all users? And how to add, delete, modify users?



To list all users you can use:
$ cut -d: -f1 /etc/passwd
To add a new user you can use:
$ sudo adduser new_username
or:
$ sudo useradd new_username
See also: What is the difference between adduser and useradd?
To remove/delete a user, first you can use: (2 commands for username and directory)
$ sudo userdel username
Then you may want to delete the home directory for the deleted user account :
$ sudo rm -r /home/username


(Please use with caution the above command!)
To modify the username of a user:
$ usermod -l new_username old_username
To change the password for a user:
$ sudo passwd username
To change the shell for a user:
$ sudo chsh username
To change the details for a user (for example real name):
$ sudo chfn username
And, of course, see also: man adduser, man useradd, man userdel... and so on.