Setup GitHub in Linux


I should have done this earlier – to use GitHub to manage my scripts/configs/documentations. So I can have them managed and tracked. Later better than never, I got them setup Today in my Ubuntu box. Here is the how to:

1) Go to the GitHub.com to create an account.

2) Install git client.

jchen@mylaptop:~$ sudo apt-get install git -y

3) Configure the git user info and password caching.

jchen@mylaptop:~$ git config –global user.name “jchen”
jchen@mylaptop:~$ git config –global user.email “xxx@xxx.xxx”
jchen@mylaptop:~$ git config –global credential.helper cache
jchen@mylaptop:~$ git config –global credential.helper ‘cache –timeout=3600’

4) Go to GitHub.com to create a repository, my first repository is bash-scripts

5) Initialize the Git local repository in ~/Google Drive/scripts/bash-scripts

jchen@mylaptop:~/Google Drive/scripts$ mkdir bash-scripts
jchen@mylaptop:~/Google Drive/scripts$ cd bash-scripts
jchen@mylaptop:~/Google Drive/scripts/bash-scripts$ git init
Initialized empty Git repository in /home/jchen/Google Drive/scripts/bash-scripts/.git/

6) Create README file in local repository, and add some descriptions.
jchen@mylaptop:~/Google Drive/scripts/bash-scripts$ touch README
jchen@mylaptop:~/Google Drive/scripts/bash-scripts$ vi README

7) Add README file to the commit list, then commit it.
jchen@mylaptop:~/Google Drive/scripts/bash-scripts$ git add README
jchen@mylaptop:~/Google Drive/scripts/bash-scripts$ git commit -m ‘general info’

8) Create a remote repository pointing to GitHub.com, and push my commits to it.
jchen@mylaptop:~/Google Drive/scripts/bash-scripts$ git remote add origin https://github.com/jc1518/bash-scripts.git
jchen@mylaptop:~/Google Drive/scripts/bash-scripts$ git push origin master
Username for ‘https://github.com’: jc1518
Password for ‘https://jc1518@github.com’:
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 252 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/jc1518/bash-scripts.git
* [new branch] master -> master

9) Add/Copy my first code to the local repository, and commit it, then push it to GitHub repository.
jchen@mylaptop:~/Google Drive/scripts/bash-scripts$ mkdir wallpaper-of-the-day
jchen@mylaptop:~/Google Drive/scripts/bash-scripts$ cp /usr/bin/wod wallpaper-of-the-day/
jchen@mylaptop:~/Google Drive/scripts/bash-scripts$ git add wallpaper-of-the-day/
jchen@mylaptop:~/Google Drive/scripts/bash-scripts$ git commit -m ‘wod first submit’
[master 73319e7] wod first submit
1 file changed, 27 insertions(+)
create mode 100755 wallpaper-of-the-day/wod
jchen@mylaptop:~/Google Drive/scripts/bash-scripts$ git push origin master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 723 bytes | 0 bytes/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To https://github.com/jc1518/bash-scripts.git
6dfe1e4..73319e7 master -> master

Advertisement

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 )

Connecting to %s