Introduction to Github with Egit
2014
/YuMatsuzawa/
Github??
• Google it, now.
• Or, https://github.com/
Introduction to Github 2
Github??
Introduction to Github 3
Github??
Introduction to Github 4
Make your account,
now.
Github??
Introduction to Github 5
Make your account,
now.
Or, Login if already got one.
You will see…
Introduction to Github 6
You will see…
Introduction to Github 7
…then you are ready.
LOLWATTZDIS?
• With Github, you can…
– Find/Clone/Help someone else’s nice projects.
– Sync your progress across multiple ...
LOLWATSDIS?
• With Github, you can…
– Find/Clone/Help someone else’s nice projects.
– Sync your progress across multiple m...
LOLWATSDIS?
• With Github, you can…
– Find/Clone/Help someone else’s nice projects.
– Sync your progress across multiple m...
LOLWATSDIS?
• With Github, you can…
– Find/Clone/Help someone else’s nice projects.
– Sync your progress across multiple m...
LOLWATSDIS?
• With Github, you can…
– Find/Clone/Help someone else’s nice projects.
– Sync your progress across multiple m...
Now you know Github is
• Platform of distributed development for
Open Source Software using Git
– Actually, not limited to...
From Where?
• Basic Git is CUI thing
– You may learn/use Git this way, and actually, sometimes, for
some kind of people, i...
Requirement
• Any working Eclipse (not too old one)
• ssh-keygen
– Included in recent versions of Eclipse
– Other ways:
• ...
EGit
• … is Eclipse plugin for Git.
• Install it.
1. Launch Eclipse
2. Help > Eclipse Marketplace
3. Search “EGit”
4. Inst...
Prepare SSH public key
• Stay in Eclipse
• Open “設定”(Preferences)
– “一般”(General)>”ネットワーク接続”(Network
Connection)>”SSH2”
– ...
Prepare SSH public key
• If you already got one, new key isn’t required
– Found “<user>/.ssh/id_rsa.pub” ? => Done.
• On M...
Prepare SSH public key
• On PuTTY:
– Find PuTTYGen in PuTTY install directory
– “生成”(Generate)
– (Move cursor around)
– “変...
Prepare SSH public key
– Copy this
• PuTTYGen generate original format ssh key
• OpenSSH format key required
• This is for...
Register public key
Introduction to Github 21
Register public key
Introduction to Github 22
Register public key
Introduction to Github 23
Register public key
Introduction to Github 24
Register public key
Introduction to Github 25
Register public key
Introduction to Github 26
Register public key
Introduction to Github 27
Register public key
Introduction to Github 28
Paste the content of generated id_rsa.pub here
Appropriate title
Specify SSH private key for Eclipse
• Generated your key via Eclipse? => Done.
• If not:
– Your key is <user>/.ssh/id_rsa?...
Authentication Method
• “認証方法”(Authentication Methods)
• Uncheck “password”
– Only key authentication
• Now everything rea...
Create Repository
• What’s “repository”?
– Storage for Git objects
– There must be remote repository on Github AND
local r...
Create Remote Repository
Introduction to Github 32
Create Remote Repository
Introduction to Github 33
Create Remote Repository
Introduction to Github 34
Create Remote Repository
Introduction to Github 35
Appropriate title
Description
Cannot choose Private
on unpaid account
M...
Create Remote Repository
Introduction to Github 36
Done.
Share your existing project
• Open your project
• Right click
• チーム”Team”
• プロジェクトの共用
“Share the project”
• “Git”
Introduc...
Create Local Repository
Introduction to Github 38
Create Local Repository
• Where to reposit?
– Recommended: Distinct, new path dedicated only for
that repository outside o...
Create Local Repository
• Where to reposit?
– Recommended: Distinct, new path dedicated only for
that repository outside o...
Create Local Repository
Introduction to Github 41
Create Local Repository
Introduction to Github 42
Create Local Repository
Introduction to Github 43
Create Local Repository
Introduction to Github 44
Aforementioned recommendation
Ignore warning and create repo
Create Local Repository
• If you are to place your repo outside of Eclipse
workspace…
Introduction to Github 45
Create Local Repository
• If you are to place your repo outside of Eclipse
workspace…
Introduction to Github 46
Default pa...
Introduction to Github 47
Repository Ready
Introduction to Github 48
Repository Ready
Open Git repositories pane.
ウィンドウ>ビューの表示>その他>チーム
Indicators appeared
(‘>’,’?’,’...
A little backtracking
• It’s good time to learn how exactly Git works.
Introduction to Github 49
A little backtracking
• It’s good time to learn how exactly Git works.
Introduction to Github 50
GithubYour Machine
Your E...
A little backtracking
• You’ve created repositories.
Introduction to Github 51
Github
Your Eclipse
Remote RepositoryLocal ...
A little backtracking
• Obviously, you want to store your project.
• …but making repository is just
a first step.
Introduc...
A little backtracking
• Inside repos are indexes (file lists)
• Indexes track what files belong
to the repos
Introduction ...
A little backtracking
• Inside repos are indexes (file lists)
• Indexes track what files belong
to the repos
• You can ‘gi...
A little backtracking
• Now the local repo knows your files
• But only their existence.
• Repo must know if files are
read...
A little backtracking
• Your next move is to register your progress
•
•
Introduction to Github 56
Github
Your Eclipse
Remo...
A little backtracking
• Your next move is to register your progress.
• ‘git commit’ is the way to go.
• Records your curre...
A little backtracking
• You commit to a specific “branch”
• Branch = Front-ends of devel.
flows (latest commits)
First com...
A little backtracking
• If you modify your files and commit again,
•
Introduction to Github 59
Github
Your Eclipse
Remote ...
A little backtracking
• If you modify your files and commit again,
• …that records are committed
to currently targeted bra...
A little backtracking
• You can make another branch
•
Introduction to Github 61
Github
Your Eclipse
Remote RepositoryLocal...
A little backtracking
• You can make another branch
• Committing to another branch
will separate the flow.
Introduction to...
A little backtracking
• You can make another branch
• Committing to another branch
will separate the flow.
• Also you can ...
A little backtracking
• If branches conflict (like edited same file),
•
Introduction to Github 64
Github
Your Eclipse
Remo...
A little backtracking
• If branches conflict (like edited same file),
• …Git notifies conflicting files.
Introduction to G...
A little backtracking
• If branches conflict (like edited same file),
• …Git notifies conflicting files.
• Then you must m...
A little backtracking
• If branches conflict (like edited same file),
• …Git notifies conflicting files.
• Then you must m...
A little backtracking
• Anyway, let’s go committing for now!
• Back to Eclipse…
Introduction to Github 68
Github
Your Ecli...
Introduction to Github 69
Add/Commit
Indicators appeared
(‘>’,’?’,’[NO-HEAD]’,…)
Introduction to Github 70
Add/Commit
These indicator means:
> -Uncommitted changes exists
? -Not added to the index
* -Add...
Introduction to Github 71
Add/Commit
• Right click on the project,
• “チーム”(Team),
• You’ll find its contents changed
• “コミ...
Introduction to Github 72
Add/Commit
• (This window can differ from an Eclipse
version to another, this is Juno 4.2.2)
• C...
Add/Commit
• Gratz! Your first LOCAL commit
(+ add) is made.
• You notice the ‘>’ indicator
disappeared from the project.
...
“Remote Control”
• Next step is to interact with the remote repo.
•
Introduction to Github 74
Github
Your Eclipse
Remote R...
“Remote Control”
• Next step is to interact with the remote repo.
• Remote contents are managed
with similar branch system...
“Remote Control”
• Now, you need special local branch.
•
Introduction to Github 76
Github
Your Eclipse
Remote RepositoryLo...
“Remote Control”
• Now, you need special local branch.
• So-called “remote tracking”
• This branch tracks/syncs with
statu...
“Remote Control”
• ‘origin’ means it’s your primary remote repo.
• ‘origin/master’ means it syncs
with ‘master’ branch on ...
“Remote Control”
• Tracker will ‘git fetch’ the remote contents.
• The first fetch creates the
remote tracker.
Introductio...
“Remote Control”
• Then you merge 2 local branches.
•
Introduction to Github 80
Github
Your Eclipse
Remote RepositoryLocal...
“Remote Control”
• Then you merge 2 local branches.
• Now local ‘master’ contains all
contents from local & remote.
Introd...
“Remote Control”
• With fetch & merge, local branch is up-to-date
• Normally you do this before
starting your work of the ...
“Remote Control”
• Next move obviously, is going opposite way
•
Introduction to Github 83
Github
Your Eclipse
Remote Repos...
“Remote Control”
• Next move obviously, is going opposite way
• At this point all tools are set.
• ‘git push’ will do the ...
“Remote Control”
• So, in summary:
• Pull (fetch & merge). Remote
tracker created. (Do work.)
Push. Done. Let’s do this ->...
Remote Configuration
Introduction to Github 86
Back to Web Browsers.
Your Remote Repo page.
Remote Configuration
Introduction to Github 87
Back to Web Browsers.
Your Remote Repo page.
Copy this address.
Make sure i...
Remote Configuration
Introduction to Github 88
Remote Configuration
Introduction to Github 89
In the Repo Pane, under the repo
> “リモート”(Remote)
Remote Configuration
Introduction to Github 90
Right click
> “リモートの作成”(Create a remote)
In the Repo Pane, under the repo
>...
Remote Configuration
• Making push configuration first would be a
little easier.
Introduction to Github 91
Push Configuration
Introduction to Github 92
Click this to expand
Push Configuration
Introduction to Github 93
PushConfiguration
Introduction to Github 94
Your copied address should automatically
be inserted from clipboard.
No need t...
Push Configuration
Introduction to Github 95
Push Configuration
Introduction to Github 96
What was HEAD?
> Reference to current branch.
Click & focus here, then hit Ct...
Push Configuration
Introduction to Github 97
Complement service will automatically
search existing remote branches.
Choose...
Push Configuration
Introduction to Github 98
Checking this has literal meaning.
When pushing, it will ignore push
rejectio...
Push Configuration
Introduction to Github 99
Push Configuration
Introduction to Github 100
• Repositories Pane should now be like this.
Push Configuration
Introduction to Github 101
• Repositories Pane should now be like this.
• Right click on ‘origin’
• “フェ...
Fetch Configuration
Introduction to Github 102
Fetch Configuration
Introduction to Github 103
Exactly the same as push
Fetch Configuration
Introduction to Github 104
Fetch Configuration
Introduction to Github 105
Again, click & focus here, then hit Ctrl+Space.
Choose ‘master’.
Fetch Configuration
Introduction to Github 106
Another overwrite option.
Better not check.
Fetch Configuration
Introduction to Github 107
Now that fetch configuration is ready,
let’s try fetching for the first tim...
Fetch
Introduction to Github 108
Result should be like this.
Server certification acceptance may be
prompted.
Remote Tracking Branch
• Under “ブランチ”(Branch)
>”リモート・トラッキング”(Remote tracking),
you will find ‘origin/master’
• To reflect ...
Merge
• Right click on the remote tracker
• “マージ”(Merge)
Introduction to Github 110
Merge
• At this time, result should be like this.
• Key is ‘Fast-forward’(FF)
– Basically means no conflicts there.
– To b...
Merge
• Here comes README from the
remote joining the local.
• Finally, to upload this merged
commit to the remote…
Introd...
Push
Introduction to Github 113
2 ways of doing this:
Right click on the project
> “チーム”(Team)
>”アップストリームへプッシュ”
(Push to u...
Push
Introduction to Github 114
• Result should be like this.
• At this time no rejection for sure.
Check on Github
Introduction to Github 115
Back to Web Browsers.
Try refresh.
Check on Github
Introduction to Github 116
Happy face 
Easier way for daily use
• Now the very basic git usage is covered.
• May pull / commit and push as shortcut.
Introduction...
Versioning
• Versioning is done through tagging in git.
• You may noticed “タグ”(Tag) in the repo pane.
• Right click and “タ...
Tag
Introduction to Github 119
Hit this to expand
Tag
Introduction to Github 120
Appropriate name (such as v1.0, v2.4-beta)
Description message
Choose a commit you want to ...
Tag
• Now that commits are tagged.
• If you want to publish these tags (versions),
you need to push tags manually.
– Not t...
Push Tag
• Right click on the tag > “Push Tag”
• “構成済みレポジトリー”
(Configured Repository)
• Hit Next
Introduction to Github 122
Push Tag
• Tricky part: Tags are referred like
‘refs/tags/<tag name>’.
Introduction to Github 123
Push Tag
• Tricky part: Tags are referred like
‘refs/tags/<tag name>’.
• You need to manually
specify this.
Introduction t...
Push Tag
• Tricky part: Tags are referred like
‘refs/tags/<tag name>’.
• You need to manually
specify this.
• Basically ju...
Push Tag
• Result should be like the left
• On Github, ‘releases’ should appear and you
can see the version history
Introd...
Versioning
• Versioning itself needs its own philosophy and
practice, and it’s ultimately depends on how
the team will han...
From Remote, Comes…
• So far, we assumed you have your local project
developed without using git.
• And how to integrate i...
Clone
• You can ‘git clone’ the remote repo itself.
•
Introduction to Github 129
Github
Your Eclipse
Remote Repository
You...
Clone
• You can ‘git clone’ the remote repo itself.
• And it’s really easy!
• Not only it copies contents of
the repo, it ...
Clone
• All you need is…
• Copy.
Introduction to Github 131
This.
Clone
• On your target machine,
• Right click on the blank area of the repo pane.
• “リポジトリー・パスまたはURIの貼り付け”
Introduction to...
Clone
Introduction to Github 133
Same as before.
Clone
Introduction to Github 134
You cannot clone to
non-empty path.
If the repo includes Java project,
you can also impor...
Clone
• With cloning, you can duplicate your Eclipse
project env. on another machine with ease.
– As long as you respect t...
Clone/Fork
• You can clone other developer’s repository,
and modify on branches as you like.
– You may do this on Github a...
.gitignore
• Sometimes you want certain files to stay
untracked/excluded from index.
– Especially data including privacy i...
Back to the Past
• So how to return to previous state?
• 1-step back (just want to discard 1 commit):
– Already pushed? > ...
Other stuff
• There are many more functions in git
– Notably rebase.
• But for now, that’s it!
– For personal/laboratory u...
CUI (Git for Windows required)
• $ cd <project directory>
• $ git init #repo created
• $ git add <files to be added>
• $ g...
Upcoming SlideShare
Loading in …5
×

Introduction to github using Egit

519 views

Published on

For laboratory seminar. Introduction to Github using Egit.

Published in: Software, Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
519
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
11
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Introduction to github using Egit

  1. 1. Introduction to Github with Egit 2014 /YuMatsuzawa/
  2. 2. Github?? • Google it, now. • Or, https://github.com/ Introduction to Github 2
  3. 3. Github?? Introduction to Github 3
  4. 4. Github?? Introduction to Github 4 Make your account, now.
  5. 5. Github?? Introduction to Github 5 Make your account, now. Or, Login if already got one.
  6. 6. You will see… Introduction to Github 6
  7. 7. You will see… Introduction to Github 7 …then you are ready.
  8. 8. LOLWATTZDIS? • With Github, you can… – Find/Clone/Help someone else’s nice projects. – Sync your progress across multiple machines. – Roll back your project to previous state. – Publish/Share your project. • “Git” is one of many Version Control Systems (VCS). • Github is one of public platforms (hubs) of Git. Introduction to Github 8
  9. 9. LOLWATSDIS? • With Github, you can… – Find/Clone/Help someone else’s nice projects. – Sync your progress across multiple machines. – Roll back your project to previous state. – Publish/Share your project. • “Git” is one of many Version Control Systems (VCS). • Github is one of public platforms (hubs) of Git. Introduction to Github 9 • Seems nice, but what is ‘cloning’?  Cloning a project is basically copying it to your machine/environment to extend it as you like.  You can clone any public projects including very famous one such as jQuery (/jQuery/jQuery) • How to help someone?  Clone their project, modify, and offer your help as ‘pull request’ (covered later)
  10. 10. LOLWATSDIS? • With Github, you can… – Find/Clone/Help someone else’s nice projects. – Sync your progress across multiple machines. – Roll back your project to previous state. – Publish/Share your project. • “Git” is one of many Version Control Systems (VCS). • Github is one of public platforms (hubs) of Git. Introduction to Github 10 • Thanks a bunch! But how?  Covered later in detail; in a few words: 1. Uploading your progress to Github 2. Downloading it to other machines 3. (Conflict shall be checked/marked) • Is it automatic?  NO. Why? Covered later.
  11. 11. LOLWATSDIS? • With Github, you can… – Find/Clone/Help someone else’s nice projects. – Sync your progress across multiple machines. – Roll back your project to previous state. – Publish/Share your project. • “Git” is one of many Version Control Systems (VCS). • Github is one of public platforms (hubs) of Git. Introduction to Github 11 • Why this is important?  When you mess up with your project and it stops working (happens often), you can come back to the point it had worked. • To any states before? Any limit?  No limitation. Github doesn’t have “max space.” You’ll see why.
  12. 12. LOLWATSDIS? • With Github, you can… – Find/Clone/Help someone else’s nice projects. – Sync your progress across multiple machines. – Roll back your project to previous state. – Publish/Share your project. • “Git” is one of many Version Control Systems (VCS). • Github is one of public platforms (hubs) of Git. Introduction to Github 12 • Could be useful… but can I keep it private?  NO. This is why github is free AND space- unlimited. Projects uploaded on github is considered public assets(or Open Source Software) thus forcibly published. • Really?  …Unless you pay at least $7/month.
  13. 13. Now you know Github is • Platform of distributed development for Open Source Software using Git – Actually, not limited to software. Any contents can be managed on github (images, .doc, .xls, etc.) – You must acknowledge contents on Github is published, thus you shouldn’t upload restricted contents (such as data including private info.) – Let’s delve into “How” Introduction to Github 13
  14. 14. From Where? • Basic Git is CUI thing – You may learn/use Git this way, and actually, sometimes, for some kind of people, it’s even easier. But for now… • Let’s do this from Eclipse GUI (for Java users) Introduction to Github 14
  15. 15. Requirement • Any working Eclipse (not too old one) • ssh-keygen – Included in recent versions of Eclipse – Other ways: • On Mac/Linux this is innately installed • On Windows: – If you have cygwin installed, you’re OK. – If you have PuTTY or TeraTerm installed, you’re OK. – Otherwise, install TeraTerm. » PuTTY and TeraTerm are both terminal emulator. For OpenSSH keygen purpose, TeraTerm is simpler and easier. Introduction to Github 15
  16. 16. EGit • … is Eclipse plugin for Git. • Install it. 1. Launch Eclipse 2. Help > Eclipse Marketplace 3. Search “EGit” 4. Install Introduction to Github 16
  17. 17. Prepare SSH public key • Stay in Eclipse • Open “設定”(Preferences) – “一般”(General)>”ネットワーク接続”(Network Connection)>”SSH2” – “鍵管理”(Key Management) – “RSA鍵の生成”(Generate RSA Key) – “秘密鍵の保管”(Save Private Key) • Default name would be “id_rsa” • Path should be <user>/.ssh/ Introduction to Github 17
  18. 18. Prepare SSH public key • If you already got one, new key isn’t required – Found “<user>/.ssh/id_rsa.pub” ? => Done. • On Mac/Linux or Cygwin: – Launch Terminal or Cygwin – Type “ssh-keygen” • Save/Move your key under <user>/.ssh/ • On TeraTerm: – Cancel “新しい接続” – “設定” > “SSH鍵生成” • Save under <user>/.ssh/ Introduction to Github 18
  19. 19. Prepare SSH public key • On PuTTY: – Find PuTTYGen in PuTTY install directory – “生成”(Generate) – (Move cursor around) – “変換”(Convert) >“OpenSSH形式” • This is for private key – Save as appropriate name • Default: <user>/.ssh/id_rsa • No extension needed Introduction to Github 19
  20. 20. Prepare SSH public key – Copy this • PuTTYGen generate original format ssh key • OpenSSH format key required • This is for pubic key – Open text editor – Paste – Save as appropriate name • Default: “id_rsa.pub” Introduction to Github 20
  21. 21. Register public key Introduction to Github 21
  22. 22. Register public key Introduction to Github 22
  23. 23. Register public key Introduction to Github 23
  24. 24. Register public key Introduction to Github 24
  25. 25. Register public key Introduction to Github 25
  26. 26. Register public key Introduction to Github 26
  27. 27. Register public key Introduction to Github 27
  28. 28. Register public key Introduction to Github 28 Paste the content of generated id_rsa.pub here Appropriate title
  29. 29. Specify SSH private key for Eclipse • Generated your key via Eclipse? => Done. • If not: – Your key is <user>/.ssh/id_rsa? => Done. – If not: • Open “設定” • “一般”>”ネットワーク接続”>”SSH2” • “秘密鍵の追加”(Add Private Key) • Specify your key name – Make sure it’s stored under <user>/.ssh/ Introduction to Github 29
  30. 30. Authentication Method • “認証方法”(Authentication Methods) • Uncheck “password” – Only key authentication • Now everything ready! Introduction to Github 30
  31. 31. Create Repository • What’s “repository”? – Storage for Git objects – There must be remote repository on Github AND local repository on your machine – Concept: Transactions are done between repositories (specific locations) Introduction to Github 31
  32. 32. Create Remote Repository Introduction to Github 32
  33. 33. Create Remote Repository Introduction to Github 33
  34. 34. Create Remote Repository Introduction to Github 34
  35. 35. Create Remote Repository Introduction to Github 35 Appropriate title Description Cannot choose Private on unpaid account Make README
  36. 36. Create Remote Repository Introduction to Github 36 Done.
  37. 37. Share your existing project • Open your project • Right click • チーム”Team” • プロジェクトの共用 “Share the project” • “Git” Introduction to Github 37
  38. 38. Create Local Repository Introduction to Github 38
  39. 39. Create Local Repository • Where to reposit? – Recommended: Distinct, new path dedicated only for that repository outside of Eclipse workspace • Not the same as the already existing project directory (usually in Eclipse workspace) • Why? -> Several reasons. Primarily for future use when you would want to place multiple projects in that repo. • Faster (Git only cares about files inside the repo) – Easier to understand: Project directory • No need to move files (easier to initialize) • Sometimes slower (Git starts to check files in workspace) Introduction to Github 39
  40. 40. Create Local Repository • Where to reposit? – Recommended: Distinct, new path dedicated only for that repository outside of Eclipse workspace • Not the same as the already existing project directory (usually in Eclipse workspace) • Why? -> Several reasons. Primarily for future use when you would want to place multiple projects in that repo. • Faster (Git only cares about files inside the repo) – Easier to understand/start: Project directory • No need to move files (easier to initialize) • Sometimes slower (Git starts to check files in workspace) Introduction to Github 40 …If you are certain about 1 project <-> 1 repo philosophy Go to
  41. 41. Create Local Repository Introduction to Github 41
  42. 42. Create Local Repository Introduction to Github 42
  43. 43. Create Local Repository Introduction to Github 43
  44. 44. Create Local Repository Introduction to Github 44 Aforementioned recommendation Ignore warning and create repo
  45. 45. Create Local Repository • If you are to place your repo outside of Eclipse workspace… Introduction to Github 45
  46. 46. Create Local Repository • If you are to place your repo outside of Eclipse workspace… Introduction to Github 46 Default path would be /<user>/git/ After proceeding, project migration to new path will begin.
  47. 47. Introduction to Github 47 Repository Ready
  48. 48. Introduction to Github 48 Repository Ready Open Git repositories pane. ウィンドウ>ビューの表示>その他>チーム Indicators appeared (‘>’,’?’,’[NO-HEAD]’,…)
  49. 49. A little backtracking • It’s good time to learn how exactly Git works. Introduction to Github 49
  50. 50. A little backtracking • It’s good time to learn how exactly Git works. Introduction to Github 50 GithubYour Machine Your Eclipse
  51. 51. A little backtracking • You’ve created repositories. Introduction to Github 51 Github Your Eclipse Remote RepositoryLocal Repository Your Machine
  52. 52. A little backtracking • Obviously, you want to store your project. • …but making repository is just a first step. Introduction to Github 52 Github Your Eclipse Remote RepositoryLocal Repository Your Machine
  53. 53. A little backtracking • Inside repos are indexes (file lists) • Indexes track what files belong to the repos Introduction to Github 53 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -… -… -… Index -… -… -…
  54. 54. A little backtracking • Inside repos are indexes (file lists) • Indexes track what files belong to the repos • You can ‘git add’ to the index Introduction to Github 54 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… ‘git add’!! Added!
  55. 55. A little backtracking • Now the local repo knows your files • But only their existence. • Repo must know if files are ready to be shared/launched Introduction to Github 55 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -…
  56. 56. A little backtracking • Your next move is to register your progress • • Introduction to Github 56 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -…
  57. 57. A little backtracking • Your next move is to register your progress. • ‘git commit’ is the way to go. • Records your current progress on indexed files to the repo. Introduction to Github 57 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… ‘git commit’!!
  58. 58. A little backtracking • You commit to a specific “branch” • Branch = Front-ends of devel. flows (latest commits) First commit creates ‘master’ Introduction to Github 58 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… c00 master Created!
  59. 59. A little backtracking • If you modify your files and commit again, • Introduction to Github 59 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… ‘git commit’!! master c00
  60. 60. A little backtracking • If you modify your files and commit again, • …that records are committed to currently targeted branch (in this case ‘master’). New one becomes branch. Introduction to Github 60 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… master c00 c01
  61. 61. A little backtracking • You can make another branch • Introduction to Github 61 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… master c00 c01 c02 c03 another
  62. 62. A little backtracking • You can make another branch • Committing to another branch will separate the flow. Introduction to Github 62 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… master c00 c01 c02 c03 a01a00 another
  63. 63. A little backtracking • You can make another branch • Committing to another branch will separate the flow. • Also you can merge them. Introduction to Github 63 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… master c00 c01 c02 c03 a01a00 m00
  64. 64. A little backtracking • If branches conflict (like edited same file), • Introduction to Github 64 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… master c00 c01 c02 c03 a01a00 another
  65. 65. A little backtracking • If branches conflict (like edited same file), • …Git notifies conflicting files. Introduction to Github 65 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… master c00 c01 c02 c03 a01a00 another
  66. 66. A little backtracking • If branches conflict (like edited same file), • …Git notifies conflicting files. • Then you must manually fix conflicts then add again. Introduction to Github 66 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… master c00 c01 c02 c03 a01a00 another Fix & ‘git add’!!
  67. 67. A little backtracking • If branches conflict (like edited same file), • …Git notifies conflicting files. • Then you must manually fix conflicts then add again. Introduction to Github 67 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… master c00 c01 c02 c03 a01a00 m00
  68. 68. A little backtracking • Anyway, let’s go committing for now! • Back to Eclipse… Introduction to Github 68 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… c00 master Created!
  69. 69. Introduction to Github 69 Add/Commit Indicators appeared (‘>’,’?’,’[NO-HEAD]’,…)
  70. 70. Introduction to Github 70 Add/Commit These indicator means: > -Uncommitted changes exists ? -Not added to the index * -Added but uncommitted (‘staged’) [<branch name>] -Current branch** **Pointer/cursor to current branch is called ‘HEAD’. ‘NO-HEAD’ means no branch specified. Indicators appeared (‘>’,’?’,’[NO-HEAD]’,…)
  71. 71. Introduction to Github 71 Add/Commit • Right click on the project, • “チーム”(Team), • You’ll find its contents changed • “コミット”(Commit) • (You can do the same thing by right-clicking the repository from the repositories pane.)
  72. 72. Introduction to Github 72 Add/Commit • (This window can differ from an Eclipse version to another, this is Juno 4.2.2) • Commit Message is important feature used for explaining what changes are made. • Keep it simple but understandable • If there are untracked files, you can add them here. (Check this “Show untracked”) Hit “Commit” if messages/adding files are ready
  73. 73. Add/Commit • Gratz! Your first LOCAL commit (+ add) is made. • You notice the ‘>’ indicator disappeared from the project. – This means the local repository now stored your progress. Introduction to Github 73
  74. 74. “Remote Control” • Next step is to interact with the remote repo. • Introduction to Github 74 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… c00 master Created!
  75. 75. “Remote Control” • Next step is to interact with the remote repo. • Remote contents are managed with similar branch system. • On repo creation, remote ‘master’ was also made. Introduction to Github 75 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… c00 master r00 master
  76. 76. “Remote Control” • Now, you need special local branch. • Introduction to Github 76 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… r00 masterc00 master
  77. 77. “Remote Control” • Now, you need special local branch. • So-called “remote tracking” • This branch tracks/syncs with status of remote branch. Introduction to Github 77 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… r00 master r00 origin/master c00 master
  78. 78. “Remote Control” • ‘origin’ means it’s your primary remote repo. • ‘origin/master’ means it syncs with ‘master’ branch on your remote repo. Introduction to Github 78 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… r00 master r00 origin/master *These are just a common tactics to name a remote tracker. You may name yours as you want. c00 master
  79. 79. “Remote Control” • Tracker will ‘git fetch’ the remote contents. • The first fetch creates the remote tracker. Introduction to Github 79 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… r00 master r00 origin/master Created! ‘git fetch’!! c00 master
  80. 80. “Remote Control” • Then you merge 2 local branches. • Introduction to Github 80 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… c00 master r00 master r00 origin/master
  81. 81. “Remote Control” • Then you merge 2 local branches. • Now local ‘master’ contains all contents from local & remote. Introduction to Github 81 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… c00 master r00 master r00 origin/master m00 *In distributed developments, conflicts can happen on this phase. **If you followed this instruction, local ‘master’ contains your local project and initially created README from remote at this moment.
  82. 82. “Remote Control” • With fetch & merge, local branch is up-to-date • Normally you do this before starting your work of the day. • You may just ‘git pull’ here. Introduction to Github 82 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… c00 master r00 master r00 origin/master m00 *Pull basically means ‘fetch then merge’ combined.
  83. 83. “Remote Control” • Next move obviously, is going opposite way • Introduction to Github 83 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… c00 master r00 master r00 origin/master m00
  84. 84. “Remote Control” • Next move obviously, is going opposite way • At this point all tools are set. • ‘git push’ will do the trick. Introduction to Github 84 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… c00 master r00 master r00 origin/master m00 *Push will commit to the remote tracker, then sync it to the branch on the remote by uploading/overwriting contents. **Again, conflicts can happen here, and your push sometimes ‘rejected’ by the remote. If so, you need to fetch & merge. r01 ‘git push’!! r01
  85. 85. “Remote Control” • So, in summary: • Pull (fetch & merge). Remote tracker created. (Do work.) Push. Done. Let’s do this -> Introduction to Github 85 Github Your Eclipse Remote RepositoryLocal Repository Your Machine Index -File1 -File2 -… Index -… -… -… c00 master r00 master r00 origin/master m00 r01 r01
  86. 86. Remote Configuration Introduction to Github 86 Back to Web Browsers. Your Remote Repo page.
  87. 87. Remote Configuration Introduction to Github 87 Back to Web Browsers. Your Remote Repo page. Copy this address. Make sure its ‘SSH’. *You registered SSH key, so you can pull/push via SSH connection. **You can pull via HTTPS, but cannot push.
  88. 88. Remote Configuration Introduction to Github 88
  89. 89. Remote Configuration Introduction to Github 89 In the Repo Pane, under the repo > “リモート”(Remote)
  90. 90. Remote Configuration Introduction to Github 90 Right click > “リモートの作成”(Create a remote) In the Repo Pane, under the repo > “リモート”(Remote)
  91. 91. Remote Configuration • Making push configuration first would be a little easier. Introduction to Github 91
  92. 92. Push Configuration Introduction to Github 92 Click this to expand
  93. 93. Push Configuration Introduction to Github 93
  94. 94. PushConfiguration Introduction to Github 94 Your copied address should automatically be inserted from clipboard. No need to modify username/password. ‘git’ is global username, auth’ed by key
  95. 95. Push Configuration Introduction to Github 95
  96. 96. Push Configuration Introduction to Github 96 What was HEAD? > Reference to current branch. Click & focus here, then hit Ctrl+Space
  97. 97. Push Configuration Introduction to Github 97 Complement service will automatically search existing remote branches. Choose ‘master’ branch.
  98. 98. Push Configuration Introduction to Github 98 Checking this has literal meaning. When pushing, it will ignore push rejection from the remote branch and forcibly push the local HEAD. Generally a bad idea.
  99. 99. Push Configuration Introduction to Github 99
  100. 100. Push Configuration Introduction to Github 100 • Repositories Pane should now be like this.
  101. 101. Push Configuration Introduction to Github 101 • Repositories Pane should now be like this. • Right click on ‘origin’ • “フェッチの構成”(Configure fetch)
  102. 102. Fetch Configuration Introduction to Github 102
  103. 103. Fetch Configuration Introduction to Github 103 Exactly the same as push
  104. 104. Fetch Configuration Introduction to Github 104
  105. 105. Fetch Configuration Introduction to Github 105 Again, click & focus here, then hit Ctrl+Space. Choose ‘master’.
  106. 106. Fetch Configuration Introduction to Github 106 Another overwrite option. Better not check.
  107. 107. Fetch Configuration Introduction to Github 107 Now that fetch configuration is ready, let’s try fetching for the first time! Remember, first fetch will create the remote tracking branch ‘origin/master’
  108. 108. Fetch Introduction to Github 108 Result should be like this. Server certification acceptance may be prompted.
  109. 109. Remote Tracking Branch • Under “ブランチ”(Branch) >”リモート・トラッキング”(Remote tracking), you will find ‘origin/master’ • To reflect the remote status to local… Introduction to Github 109
  110. 110. Merge • Right click on the remote tracker • “マージ”(Merge) Introduction to Github 110
  111. 111. Merge • At this time, result should be like this. • Key is ‘Fast-forward’(FF) – Basically means no conflicts there. – To be precise, one branch is wholly older, and its recent commit is included in the other. Introduction to Github 111
  112. 112. Merge • Here comes README from the remote joining the local. • Finally, to upload this merged commit to the remote… Introduction to Github 112
  113. 113. Push Introduction to Github 113 2 ways of doing this: Right click on the project > “チーム”(Team) >”アップストリームへプッシュ” (Push to upstream) or Right click on ‘origin’ under “リモート” >”プッシュ”(Push)
  114. 114. Push Introduction to Github 114 • Result should be like this. • At this time no rejection for sure.
  115. 115. Check on Github Introduction to Github 115 Back to Web Browsers. Try refresh.
  116. 116. Check on Github Introduction to Github 116 Happy face 
  117. 117. Easier way for daily use • Now the very basic git usage is covered. • May pull / commit and push as shortcut. Introduction to Github 117
  118. 118. Versioning • Versioning is done through tagging in git. • You may noticed “タグ”(Tag) in the repo pane. • Right click and “タグの作成”(Create a tag) Introduction to Github 118
  119. 119. Tag Introduction to Github 119 Hit this to expand
  120. 120. Tag Introduction to Github 120 Appropriate name (such as v1.0, v2.4-beta) Description message Choose a commit you want to tag
  121. 121. Tag • Now that commits are tagged. • If you want to publish these tags (versions), you need to push tags manually. – Not tied to branch pushing, but the concept is exactly the same. Introduction to Github 121
  122. 122. Push Tag • Right click on the tag > “Push Tag” • “構成済みレポジトリー” (Configured Repository) • Hit Next Introduction to Github 122
  123. 123. Push Tag • Tricky part: Tags are referred like ‘refs/tags/<tag name>’. Introduction to Github 123
  124. 124. Push Tag • Tricky part: Tags are referred like ‘refs/tags/<tag name>’. • You need to manually specify this. Introduction to Github 124 Target name
  125. 125. Push Tag • Tricky part: Tags are referred like ‘refs/tags/<tag name>’. • You need to manually specify this. • Basically just copy the name above. Introduction to Github 125 Target name (refs/tags/v1.1)
  126. 126. Push Tag • Result should be like the left • On Github, ‘releases’ should appear and you can see the version history Introduction to Github 126
  127. 127. Versioning • Versioning itself needs its own philosophy and practice, and it’s ultimately depends on how the team will handle the project. • Make/follow the guideline and decide when/how often/what kind of state to publish. Introduction to Github 127
  128. 128. From Remote, Comes… • So far, we assumed you have your local project developed without using git. • And how to integrate it with git is covered. • Let’s see how to duplicate your git-integrated project to your extra machines. • Or to duplicate other’s project. – These are done with exact same procedure. Introduction to Github 128
  129. 129. Clone • You can ‘git clone’ the remote repo itself. • Introduction to Github 129 Github Your Eclipse Remote Repository Your Machine Index -… -… -… r00 master r01
  130. 130. Clone • You can ‘git clone’ the remote repo itself. • And it’s really easy! • Not only it copies contents of the repo, it automatically set all the remote configuration! Introduction to Github 130 Github Your Eclipse Remote Repository Your Machine Index -… -… -… r00 master r01 Local Repository Index -File1 -File2 -… c00 master r00 origin/master m00 r01 ‘git clone’!! Created! Created! Created! Created!
  131. 131. Clone • All you need is… • Copy. Introduction to Github 131 This.
  132. 132. Clone • On your target machine, • Right click on the blank area of the repo pane. • “リポジトリー・パスまたはURIの貼り付け” Introduction to Github 132
  133. 133. Clone Introduction to Github 133 Same as before.
  134. 134. Clone Introduction to Github 134 You cannot clone to non-empty path. If the repo includes Java project, you can also import them.
  135. 135. Clone • With cloning, you can duplicate your Eclipse project env. on another machine with ease. – As long as you respect the procedure of pull/modify/commit/push, you can work on your project from various places without an issue. – But sometimes an error will happen. And in a team development conflicts are common. • To prevent your working branch being overwritten by a problematic commit, there is no auto-pull. • To prevent not-ready code being sent to the remote, there is no auto-commit/push. Introduction to Github 135
  136. 136. Clone/Fork • You can clone other developer’s repository, and modify on branches as you like. – You may do this on Github alone, creating the remote clone of the original in your account. (Called forking.) – Note: However, pushing to original repository is only allowed to the repo’s owners. • If you have done valuable modification to the branch of cloned/forked repo, you can ‘pull request’ to the owner. • Push your branch to forked repo, then submit pull request on the original repo. Introduction to Github 136
  137. 137. .gitignore • Sometimes you want certain files to stay untracked/excluded from index. – Especially data including privacy info. • Then you can “無視” (ignore) such data. – Listed on .gitignore • After that, commit the branch – .gitignore will be added Introduction to Github 137
  138. 138. Back to the Past • So how to return to previous state? • 1-step back (just want to discard 1 commit): – Already pushed? > git revert. Making new commit. • But your code may already be used by someone. – Not pushed? > Amend commit, or reset and start over. • Multi-step back – Make new branch on the past commit, checkout (means moving your current branch(HEAD)), work on it, eventually merge with master, or discard old master and name the current as new master. – Branching is has high flexibility. Introduction to Github 138
  139. 139. Other stuff • There are many more functions in git – Notably rebase. • But for now, that’s it! – For personal/laboratory use, we learned more than enough I believe. • Utilize my account(/YuMatsuzawa/) for testing Introduction to Github 139
  140. 140. CUI (Git for Windows required) • $ cd <project directory> • $ git init #repo created • $ git add <files to be added> • $ git commit –a #commit all • $ git remote add origin <remote URI> #remote config • $ git fetch origin #fetch any branches • $ git merge origin/master #merge remote tracker • $ git push origin master #push to remote Introduction to Github 140

×