Monday, December 1, 2014

Git: Cloning a Remote Repository

Assumptions

  1. A remote GIT repository exists
  2. I want to use the project with Eclipse
  3. I want a “projects” sub-directory that does not contain Eclipse meta-data


Command Sequence

  1. mkdir shortname
  2. cd shortname
  3. git init
  4. git remote add shortname url
  5. git clone url
  6. git pull -u shortname
  7. mkdir projects
  8. cd projects
  9. mv shortname/ projects/
Open Eclipse and Import Projects! Reference “Git with Eclipse: Design Patterns”



Case Study: Clone SWTK Commons

  1. mkdir commons
  2. cd commons
  3. git init
  4. git remote add commons https://github.com/torrances/swtk-common.git
  5. git clone https://github.com/torrances/swtk-common.git
    1. Operational Output
    2.  craigtrim@W540 /c/Backup/Java/workspaces/swtk/commons (master)  
       $ git clone https://github.com/torrances/swtk-common.git  
       Cloning into 'swtk-common'...  
       remote: Counting objects: 737, done.  
       remote: Compressing objects: 100% (106/106), done.  
       remote: Total 737 (delta 17), reused 0 (delta 0)  
       Receiving objects: 100% (737/737), 1.57 MiB | 455.00 KiB/s, done.  
       Resolving deltas: 100% (237/237), done.  
       Checking connectivity... done.  
      
  6. git pull -u commons
  7. mkdir projects
  8. cd projects
  9. mv commons/ projects/



Troubleshooting

  1. Remote already exists
    1. The remote add command was already executed
    2. List existing remotes on the command line using remote -v
    3. Git Reference: Working with Remotes
  2. Git Repository Information not displayed in the Eclipse Package Overview
    1. This is not important. Git interaction should occur within the Git Shell; not within Eclipse. I do not recommend using the built-in Git plugin with Eclipse. Eclipse is useful as an IDE, but building should be handled externally (eg. via Maven) as well as repository interaction (via the Git command line).

1 comment: