Preface
This could be a guidance, for git beginner, as well.
Table of Content
-
Preface: Table of Content
-
6: Enable SSH
An article Rewritten
I have been working with git, for this my personal blog, for use with a single computer. Now, I have moved on from working with standalone single computer, to works anywhere, anytime.
I did once upon a time, wrote an article covering git for single computer.
Now, let’s forget about it, and write a whole new article from scratch. There are just a few steps, for git beginner, Each with figure:
-
Create Repository: Create a github repository.
-
First Computer: Push your first commit, with first computer.
-
Refresh Browser: Refresh browser, to see if you are succeed.
-
Second Computer: Pull your newly repo, with second computer, and make a change.
-
Back to First Computer: Pull altered repo, with first computer.
This is about moving from single.
Single Life (Edisi Jomblo)
1: Create Repository
Push your first commit, with first computer.
You have to do it manually.
Create a github account.
And then create a repository,
let’s name it anycode
.
You should see the result as below:
One small step for man, one giant leap for mankind.
2: First Computer
Push your first commit, with first computer.
Just follow this step, common guidance from github itself.
Create a directory with any name,
let’s say anycode
as our working directory.
% cd githublab
% mkdir anycode
% cd anycode
% touch README.md
% geany README.md
% git init
Initialized empty Git repository in /home/epsi/githublab/anycode/.git/
Consider create a file README.md
with content anything in your mind.
% git add README.md
% git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: README.md
% git commit -m 'I love you, honey!'
[master (root-commit) 6119e49] I love you, honey!
1 file changed, 2 insertions(+)
create mode 100644 README.md
While we see the word origin
,
as a named remote repository, scattered in most tutorial.
Actually you can name it anything you want,
such as cinta
.
Cinta is the word Love in Indonesia
% git remote add cinta https://github.com/epsi-rns/anycode.git
% git push --set-upstream cinta master
Username for 'https://github.com': epsi-rns
Password for 'https://epsi-rns@github.com':
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 270 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/epsi-rns/anycode.git
* [new branch] master -> master
Branch master set up to track remote branch master from cinta.
It means we push to the remote named cinta
,
specifically to master
branch.
Shout it loud!
3: Refresh Browser
Refresh browser, to see if you are succeed.
Consider check the result in github (on the internet cloud). You should see the result as below:
4: Second Computer
Pull your newly repo, with second computer, and make a change.
Now move to other computer.
Or for testing, just use other directory.
Create a directory with any name,
let’s say mycode
as our newly working directory.
All you have to do is pull.
again we do not need to use the word origin
.
You can name it anything you want,
such as rindu
.
Rindu is Indonesian word for Missing You
% mkdir mycode
% cd mycode
% git init
Initialized empty Git repository in /home/epsi/githublab/mycode/.git/
% git remote add rindu https://github.com/epsi-rns/anycode
% git remote --verbose
rindu https://github.com/epsi-rns/anycode (fetch)
rindu https://github.com/epsi-rns/anycode (push)
% git pull rindu master
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/epsi-rns/anycode
* branch master -> FETCH_HEAD
* [new branch] master -> rindu/master
% ls -l
total 4
-rw-r--r-- 1 epsi users 56 Jan 23 03:10 README.md
Consider make some changes.
Commit it with description such as beli bunga
.
And push to the github (on the internet cloud).
Beli bunga, means buy flower
% geany README.md
% touch TO-DO.md
% geany TO-DO.md
% git add --all
% git commit -m 'TO DO: Beli Bunga'
[master 5c517cc] TO DO: Beli Bunga
2 files changed, 2 insertions(+), 1 deletion(-)
create mode 100644 TO-DO.md
% git push -u rindu master
Username for 'https://github.com': epsi-rns
Password for 'https://epsi-rns@github.com':
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 370 bytes | 0 bytes/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To https://github.com/epsi-rns/anycode
6119e49..5c517cc master -> master
Branch master set up to track remote branch master from rindu.
You should also see changes in your browser.
Shout it loud. Again!
5: Back to First Computer
Pull altered repo, with first computer.
Now consider, going back to the first computer,
the anycode
directory,
to see if we can get the latest changes,
from the github (on the internet cloud).
All you need is to pull.
% cd anycode
% git pull
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 4 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/epsi-rns/anycode
6119e49..5c517cc master -> cinta/master
Updating 6119e49..5c517cc
Fast-forward
README.md | 2 +-
TO-DO.md | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
create mode 100644 TO-DO.md
Local repository in your first computer has been updated.
% ls -l
total 8
-rw-r--r-- 1 epsi users 70 Jan 23 04:06 README.md
-rw-r--r-- 1 epsi users 18 Jan 23 04:06 TO-DO.md
6: Enable SSH
To enable SSH. Use this URL guidance:
And do not forget to change the origin,
from https
protocol to git
.
$ git remote add origin git@github.com:epsi-rns/anycode.git
Conclusion
This is not about single computer, this is about single life.
I wish I could say loud
That’s all.
Thank you for reading