git push to github

prepare for GIT

if you just start to use git, open git bash and set config

git config --global user.email "...(your email)"

git config --gloval user.name "...(your name)"

 

set up a git repository

  1. initialize git to the project: git init
  2. create some files, you can create your config files like LICENSE, .gitignore and README.md, or you can create them later in github
  3. add all files to git: git add . (in vscode this may not success, you have to mannually commit code by the commit button in source control)

key to github

  1. generate key for project:

    ssh-keygen -t ...(key type) -b ...(key byte lenth: 4096) -C ...(same as your email)

    your key will be generated under .ssh folder in your personal user folder of your computer

  2. pop up the key:

    cat ~/.ssh/id_rsa.pub
    

    then your key will be shown and copy all of them including SSA heading and your email after ==

  3. if you have a github account, get into settings and enter SSH key setting, set up a name and paste your key under it, create and later you will receive a email from github telling you that a new public key is set

now push to github

  1. creating a new repository in github, select SSH, you will see two instrunction command line if you want to push a exsitense repository to your project in github
  2. copy the first line - make sure the terminal is now in your git repository dict, paste it and press enter, there should be no error here, if there is one, remember to enter "yes" when you are asked, this only needs to be done at first time
  3. copy the second command and paste it in your terminal, press enter, there could be an error with warning and fatal, telling your this connection fails. If no surprise, enter .git file and open config, set url = ... as below:
    url = https://github.com/(your repository address in github).git

    if failed again, go to your repository page in github, copy the address and add .git after it, just make your url is right, save this config file and try this step again.

you should see success now !

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值