avatar

How to push codes to github

[TOC]

Abstract

We can push our codes to GitHub by some methods.

We need some codes to upload our codes.

Method 1: Empty repository.

  1. Sign in to GitHub.

  2. Create a new repository, its location will be: [github_repository_url]​.

  3. Bash at local location.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    git init #Use local location as a local git repository

    git add . #Add all files into this git repository

    git commit -m "Your commit" #Push files to local git repository

    git remote add origin [github_repository_url] #Associate local repo with remote repo.

    git remote -v #Check the remote location

    git pull origin master #Pull from remote to local

    git push origin master #Push to GitHub

Method 2. Non-Empty repo

  1. Sign in to GitHub.

  2. Get the git repo, its location is [github_repository_url].

  3. Bash at local location.

    1
    git clone [github_repository_url] #Download the repo to local location.
  4. Change the codes as you need.

  5. Bash at local location.

    1
    2
    3
    4
    5
    git add . #Add all files into this git repository

    git commit -m "Your commit" #Push files to local git repository

    git push origin [Your branch] #Push to GitHub

Reference

  1. Adding an existing project to GitHub using the command line
Author: Jie
Link: https://blog.jiehua1995.xyz/post/how_to_push-codes_to_github/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Donate
  • Wechat Pay
    Wechat Pay
  • Ali Pay
    Ali Pay

Comment