Showing posts with label github. Show all posts
Showing posts with label github. Show all posts

Thursday, October 23, 2014

Retro Forking with Git and GitHub

Problem: You cloned a repository that you don't have write access to and you've done some work on it. Now you want to commit that work and push it to GitHub but you never did a fork.

1. Fork the repository, for my example I'm using https://github.com/rjrodger/seneca-mvp

2. In the console in the local repository folder do "git remote -v" to find out what the remote address is:

$ git remote -v
origin    git@github.com:rjrodger/seneca-mvp.git (fetch)
origin    git@github.com:rjrodger/seneca-mvp.git (push)

3. Add this repository as the upstream repository with "git remote add":

git remote add upstream https://github.com/rjrodger/seneca-mvp

4. "git remote -v" should now show:

$ git remote -v
origin    git@github.com:rjrodger/seneca-mvp.git (fetch)
origin    git@github.com:rjrodger/seneca-mvp.git (push)
upstream    https://github.com/rjrodger/seneca-mvp (fetch)
upstream    https://github.com/rjrodger/seneca-mvp (push)


5. Change the origin to your fork:

git remote set-url origin git@github.com:guyellis/seneca-mvp.git

6. Confirm the change:

$ git remote -v
origin    git@github.com:guyellis/seneca-mvp.git (fetch)
origin    git@github.com:guyellis/seneca-mvp.git (push)
upstream    https://github.com/rjrodger/seneca-mvp (fetch)
upstream    https://github.com/rjrodger/seneca-mvp (push)

Wednesday, June 18, 2014

Pull Requests instead of Emailing Code



If you modify code from an open source repository, such as GitHub or BitBucket, here are the reasons why you should submit a pull request to get your code back into the main repo.



  • To avoid paying the stupid tax.
    • In short, your feature or fix will be available in future versions that you might want to use. If your code doesn't get into the master branch then it makes it difficult or impossible to keep up with future versions.
  • Make open source better.
    • If you've fixed a bug or added a feature then it's highly likely that others will need that.
  • Improve your resume.
    • More and more recruiting managers are looking at what you've done when they're hiring you. Having contributed to an open source project is a great way to show that you've done real work that people are using.
  • Get Credit
    • You've done the work. Now get your name on that repo and take credit for some of the work that you've done.
  • Use the Tools
    • Do you use Git? Have you ever submitted a pull request? These are questions you might be asked at an interview. Try it and practice it so you can demonstrate this skill. Even if I was hiring a junior right out of school I'd expect them to have at least done this.
  • Understand someone else's code-base
    •  Making a contribution to someone else's code-base forces you to read their code and understand their style and way of architecting a project. This is an invaluable skill as 80% of the work you do is reading over code. Even if you wrote it you'll have forgotten it to the extent that it becomes foreign in a few months time.
 This list came from a conversation that I was having with the owner of the ABot project on GitHub. ABot is a web crawler (spider) built for speed and flexibility.


He was telling me how other developers will add features to ABot and then email the code to him. If he decides to accept the code and integrate it into the project then it's all getting committed by him under his name. He was telling me how he doesn't want the credit for this work. By not submitting your code through a pull request on GitHub it makes it very difficult to give the credit to the person who did the work.

Friday, December 6, 2013

Useful Git and GitHub Commands

My notebook for Git/GitHub commands that I find useful.

To change where your local repo thinks it originally cloned itself from drop onto a command line in the appropriate directory and:
> git remote set-url origin https://github.com/<new location>
This is useful when working with a forked repo that you want to keep up-to-date with the original repo while you're working on the fork. Allows you to flip between both of them and keep changes from both current.
Follow the above command with a 
> git pull
to update from the <new location>


Wednesday, July 24, 2013

OSCON GitHub Power Tools

The GitHub Power Tools page on the OSCON site.

Tim Berglund (GitHub, Inc.)
10:40am Wednesday, 07/24/2013

git ls-remote origin
     gets all refs
     refs are names for commits which are created in the root repo
     use if pull requestor has deleted their fork
     git has heads
     github has pull's

teach.github.com