GitHub - checking out (cloning) code

91 views
Skip to first unread message

Brian Miranda

unread,
Jul 14, 2015, 4:12:07 PM7/14/15
to landis-ii-...@googlegroups.com
Hi everyone,

I am new to GitHub and started poking around with it today.  In the process I have run into a few questions that I am hoping those with more GitHub experience can explain for me.  The first question I ran into is how to properly check out code.  I gather that in GitHub you actually just get a clone of the code and then once code changes have been committed, they are 'pushed' back to the repository.  With SVN on Google code, I was able to just checkout the portion of the code that I was interested in working with; for example the 'src' folder for a single extension.  So far with GitHub, I only see how to clone an entire repository at once (e.g., Extensions-Output).  I don't see how to check out only output-biomass, for example.  Likewise, I was thinking about making a branch for one of the extensions, but it appears that this would create a branch for the entire repository.

I got used to working with the code a certain way with SVN and Google code, and I'm sure I will get used to the way it works in GitHub as well.  I could just use a few pointers to help me figure out the GitHub equivalents to the way I used to do things.  I've done some reading on how GitHub works, and I did successfully make some code changes today and commit and push them on the repository, so it's not totally confusing to me.  I just want to make sure I'm not missing something on the checkout/cloning of code before I get too deep.  Thanks in advance for any advice!

Cheers,
-Brian

Alex Vyushkov

unread,
Jul 15, 2015, 1:31:56 AM7/15/15
to landis-ii-...@googlegroups.com
Hi Brian,

Unlike subversion, it is not possible to clone a subset of Git repository - it is all or nothing. 

Branching is very different from subversion too - there are no 'branches' directory anymore, branch is always a branch of whole repository. There is main "master" branch and as many user-created branches derived from master. So it may be a good idea to eliminate trunk/branch/tags structure in LANDIS-II git repositories in future when all old-style "branches" are merged - it is not how git works.

But do not afraid of making branches - it is very lightweight process in git, and you can switch between branches easily. BTW, you can make branches locally without pushing them to the central server (I do not recommend doing this though, but may come handy if you can coding on a plane or in Rocky Mountains and do not have Internet access)

I prefer using GUI client for working with git repositories. I use build-in git client in my Python IDE and SourceTree, but sounds like TortoiseGit is good too, and they all have UI for creating and merging branches. On a command line you do something like
git branch my_branch
git checkout my_branch
Note that 'git checkout' is totally different from 'svn checkout', it is a command to switch to a different branch instead. Very cheap operation - as you have a complete copy of your repository on your local machine.

To merge branch to master (git's term for trunk) the following commands are used (but I think this is where GUI is a must)! 
git checkout master 
git merge my_branch

Note that after "git checkout master" your local files will be overwritten with their copies in "master" branch. No worries, your changes are not lost and you can get them back by doing "git checkout my_branch"
I hope this helps and not too confusing.

If you need help on a specific problem, I'd be glad to assist. We are switching to Git here at Center for Research Computing, and running into the same problems basically.

Best Regards,
Alex

--
You received this message because you are subscribed to the Google Groups "LANDIS-II Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to landis-ii-develo...@googlegroups.com.
To post to this group, send email to landis-ii-...@googlegroups.com.
Visit this group at http://groups.google.com/group/landis-ii-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/landis-ii-developers/9a1367f0-fb4f-404f-9f47-266b66d08e4a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Alexander Vyushkov
Assistant Manager Research Programming 
Center for Research Computing
University of Notre Dame

574-631-8215 (office)

123 ITC
Notre Dame, IN 46556-5555

Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages