Wednesday, July 2, 2014

How to Push Local File into Github

After we installed the Git Dash and have a account in Github I'll show you how to push your local file into your Github account(github.com):

1. Create a  new Repository in your github which you would like to push into;

2. Installed the Git Dash

3. Then we go back to the git dash, and go to the folder directory which the file located:
Quan@QuanQuan /d/github

I have go to my D:/github folder

4. Then we get our ssh key:
$ssh -keygen -t rsa -C "your email address"

and it'll tell where exactly our ssh key file in, usually it in the (c/user/username/.ssh/id_rsa) folder.
And then we do to the folder to find the file called: id_rsa.pub, we open it and copy the whole text, this text is basically our ssh key we should add it to our own github account.

5. Add ssh key to Github Account
Go to the Account Setting -> SSH KEYS -> Add SSH key -> paste the text into "key" field and name a title as you want.

6. After we add our ssh key successfully, we go back to Git Bash to check if our ssh key has been added:
$ssh -T git@github.com
Are you sure you want to continue connecting (yes/no)? (we type yes here)
Then you'll see "you've successfully Authenticated......"
7. Then we're going to use Git Bash to add the file into Github:
$ls
This is to check all the files
Such as we want push folder “TEST” into gihub, then we need to open that folder:
$cd TEST
Then we do next steps:
$git init
$git add .
(Add all the folders into staged area)
$git status

(check git status)
$git commit -m "initial commit"
(to add our fist comment for commit)
$git log
(to check the log of commit)
8. Now we can push these codes to Gihub:
$git remote add origin (here is the ssh url for your repository in Github)
(tell git I want to add a remote repository)
$git push origin master
(upload file)
9. Finally, refresh your repository in Github, we will see the files.
10. Some words in Github we need to know:
Branching: Allows you to create a separate working copy of you code with you have duplicate the project.
Merging: Allow you to merge branches together
Cloning: Other developers can get a copy of your code from a remote
Forking: Forking is not a git term, it's a term GitHub uses to promote social coding

No comments:

Post a Comment