Skip to content

Instantly share code, notes, and snippets.

@tiandiduwuxiaoxiao
Last active February 4, 2018 15:29
Show Gist options
  • Save tiandiduwuxiaoxiao/ccb4e56aae132a255c8be9b9ddde2a98 to your computer and use it in GitHub Desktop.
Save tiandiduwuxiaoxiao/ccb4e56aae132a255c8be9b9ddde2a98 to your computer and use it in GitHub Desktop.
git & push local repository to remote master branch

Some steps about using git to init local repository and push to github

  1. First:prepare repository in github
  • Create a new repository at github and don't check 'Initialize this repository with a README' option.
  1. Second:prepare local repository in your pc
  • Go to your local resitory,(if you don't have one yet, just go to your work folder and git base here,then input git init in the terminal
  • Then you will create a local respository.
  1. Third:git config and create ssh for github
git config --global user.name 'YourName' 
git config --global user.email 'YouEmailAddress'
ssh-keygen -C “YouEmailAddress” -t rsa
  • Then add ssh to github.Go to 'C:\Users\Tim.ssh' folder and copy the content in 'id_rsa.pub' file.
  • Finally go to github setting page,select ssh keys option and add a new one
  1. Fourth:commit local changes
git add .
git commit -m 'comment info'
git remote add origin git@github.com:YourName/YourRepositroy.git
git push -u origin master
  • You can update your local repository with below command after you make changes at github directly.
git pull origin master
  • Notice:
  1. There is a period behind git add which means to add all the changes(all changed files).
  2. The instance for third command:git remote add origin git@github.com:tiandiduwuxiaoxiao/pythonProble.git and you can don't type the command again if you type it before
  • If you complete all the steps metioned above,you will see all the file in github repository same as your local repository.
  • All the steps refer this article  and I acquire success after doing all all steps in the article.Good luck!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment