Adding new Code to your GitHub Repository

http://annasob.wordpress.com/2009/10/18/adding-new-code-to-your-github-repository/


Previously, I posted a tutorial on setting up GitHub and Git Bash. Now I would like to show you how to get new code into ur repository.

Steps:

  1. Create a local Branch
  2. Create a remote Branch
  3. Add files to your local Branch
  4. Commit changes to your local Branch
  5. Push the new branch to GitHub

Those are the steps, now before we get started bookmark this Git cheat sheet its a good reference.

Note: all commands are entered in Git Bash command prompt. How do u open it? On Vista, Start -> Search for Quick->Right click ‘Quick Launch’ result->Select ‘Git Bash Here’

Create a Local Branch

A local branch is a version of your code package saved on your home machine. I believe you can have as many branches as you want.

  1. git branch <branch name>

Create a Remote Branch

A remote branch is one that sits on the GitHub social coding site, users can select this branch and download code that belongs to this branch alone.

  1. git push origin origin:refs/heads/branch name>

The command window will give you a confirmation:

Total 0 (delta 0), reused 0 (delta 0)
To git@ github.com:annasob/processing-js.git
* [new branch]      origin/HEAD -> withCursor2-

——————————————————————

Total 0 (delta 0), reused 0 (delta 0)

To git@github.com:annasob/processing-js.git

* [new branch]      origin/HEAD -> withCursor2

——————————————————————

If you get an error saying repository not found make sure your config file is correct. Here is a snippet:

——————————————————————-

[remote "origin"]

fetch = +refs/heads/*:refs/remotes/origin/*

url = git@github.com:annasob/processing-js.git

master

remote = origin

merge = refs/heads/master
——————————————————————

Add files to your local branch

I am not sure if this makes a difference, but i just opened the processing-js directory I was working in and dragged any new files/folders I needed to have.  Alternatively, you can use these commands, well first you have to tell Git which branch you are going to be working with:

  1. git checkout <local branch name>
  2. git add <filename or directory>

Commit changes to your local Branch

Before you can submit the changes to GitHub, you have to commit them on your local machine.

  1. git commit -a

This command will commit all of your changes and allow you to write a message in vim. Vim guide.

The message should be significant, as everyone will read it to see whats new from the previous versions.

Push the new branch to GitHub

Now you are ready to update the remote branch.

  1. git push git@github.com:annasob/processing-js.git <remote branch name>

Note: you will need to put your own repository path in. Here is the message you will see:

——————————————————————–

Counting objects: 7, done.

Delta compression using up to 2 threads.

Compressing objects: 100% (3/3), done.

Writing objects: 100% (5/5), 617 bytes, done.

Total 5 (delta 1), reused 0 (delta 0)

To git@github.com:annasob/processing-js.git

8e069aa..dd33dfd  withCursor -> withCursor

———————————————————————-

After you do all of this, log in to ur GitHub account and go to your repository. If you roll over ‘all branches’ you will see your new branch. Select it and try downloading the contents to ensure that nothing is missing.

Note, I have reported a bug, somehow the download functionality in GitHub doesn’t always work.

Hope this tutorial helps :) Feel free to post comments.


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值