By Dennis Ivy

📆 Posted on 2021-5-31

Upload Files to GitHub Quickstart Guide

So you have a project on your local desktop and now you want to get these files up on github.com, here’s how you can do this.

Article summary

Create Remote Repository on GitHub.com

Download Git

  1. Download Installer
  2. Install git
  3. Check Git version

Create Local Repository

> git init
> git status
> git add .
> git commit -m “Custom message”
> git remote <remote url>
> git push -u origin <branch name>

DON’T drag your files directly into your github repo!

For those of you who saw me do this in my django beginners course, I’m sorry. At the time I didn’t realize the issues this would cause. This may work in some cases but I noticed in projects with more files this tends to leave out files in the upload process, why? I have no idea, so even if it works, DON’T DO IT!

This won’t be a full Git & Github tutorial, I’m gonna assume you get the point and just need to get your files up online. For a full overview I recommend you checkout this tutorial by my friend Brad Traversy.

So, Let’s get started…

Create Remote Repository on GitGub.com

If you don’t already have an account go ahead to github.com, signup, and create a repository, this is where our files will be added.

You can create your repository by going to “repositories” and by clicking “new”

In this example I will set my project to “private” and will not be creating a readme file. If you plan on sharing your project with the world make sure you leave it as “public”

Once you create your repo you will see a quick start guide on how to commit frp, your local repository. We will ignore these instructions for now since we need to get set up locally first.

Download Git

Before we can get started we will need to download git locally in order to push files to github.

1 - Download Installer - Got to https://git-scm.com/ and select the downloader for your machine, I will be using windows

2 - Install git - Once the installer is downloaded go ahead and follow the steps to get things set up, I tend to just leave the default settings so if you don’t have a preference just let it guide you.

3 - Check git version

> git --version

Once things are installed do a quick search on your computer for git bash and open it. To check the version of git you have installed go ahead and type git --version

You can also do this from your command prompt, in fact I will be using the command prompt from now on so go ahead and close git bash and open up a new terminal.If you already had your terminal open you may need to close and reopen to get the updates.

Let’s look at a few of the commands we will be using in the next steps:

Create Local Repository

1 - Initialize new git repo

git init

Now that you have git installed, cd into your project folder and initialize a local repo.

cd projectname
git init

When you run git init a new folder will be added to your project files, these files visibility are set to “hidden” by default so you will not see them but rest assured they are there. If you want to see these files open up your folder and select “view”

2 - Check your staging area

> git status

This step is not necessary before we add our files but for the sake of seeing the difference and showing exactly what happens lets run “git status”

3 - Add files

> git add .

To add a particular file or folder to your staging area you can run “git add ”. In our case we want to add all the files highlighted in red so lets run git add .. In case you can’t see it there is a period after add indicating we want ALL the files.

After running git status I typically like to run git status again to ensure all changes we made.

What if we make changes after adding running git “add .”?

No worries, just run git add again and changes will be updated. You can always run “git status” beforehand to see exactly which files have been modified.

4 - Commit Changes

> git commit -m “Your custom note”

Now that we added files to our staging area we need to commit them to our local repository.

git commit -m “first commit”.

Files are now committed and ready to be pushed to our remote

5 - Set remote

> git remote add origin <repo url>

Now that all the files are set locally we are ready to push them to our remote repository. We set the remote so when we run git push, git knows which remote repo to send these files to.

Ex:

> git remote add origin https://github.com/divanov11/newproject.git

6 - Push to remote

> git push -u origin <branch name>

Now that we have our remote set, we can push our local github repo live. The default branch on github is called “master” unless you set your own. When you first create a repository on github you will see steps to rename this branch to “main”, if you decided to rename the default branch then use that name instead of master.

git push -u origin master

Now if you refresh your repository on github.com you should see all your local files here.

Ignore files & cloning repos

Ignoring files: Add a .gitignore file and write in the file or folder name you want to ignore.

Clone a repo: copy the url of the repo you want to clone and simply run git clone <repo url>

深圳SEO优化公司广东企业网站建设报价坑梓百度爱采购推荐温州SEO按天扣费公司昌都网站设计模板哪家好娄底网站排名优化公司爱联网站制作设计报价阜新网站设计推荐四平网站关键词优化推荐扬州建设网站哪家好桂林模板推广哪家好延安网站优化推荐安顺建设网站报价鹰潭建站哪家好果洛优秀网站设计价格垦利模板制作价格四平百度网站优化公司池州推广网站多少钱临汾关键词排名包年推广霍邱seo网站推广价格株洲高端网站设计推荐醴陵模板制作推荐泰安企业网站制作推荐湘西网站优化按天计费公司遂宁网页设计多少钱济源网页制作哪家好云浮外贸网站设计哪家好民治网站开发公司德阳seo优化多少钱临汾推广网站多少钱天津网页设计报价歼20紧急升空逼退外机英媒称团队夜以继日筹划王妃复出草木蔓发 春山在望成都发生巨响 当地回应60岁老人炒菠菜未焯水致肾病恶化男子涉嫌走私被判11年却一天牢没坐劳斯莱斯右转逼停直行车网传落水者说“没让你救”系谣言广东通报13岁男孩性侵女童不予立案贵州小伙回应在美国卖三蹦子火了淀粉肠小王子日销售额涨超10倍有个姐真把千机伞做出来了近3万元金手镯仅含足金十克呼北高速交通事故已致14人死亡杨洋拄拐现身医院国产伟哥去年销售近13亿男子给前妻转账 现任妻子起诉要回新基金只募集到26元还是员工自购男孩疑遭霸凌 家长讨说法被踢出群充个话费竟沦为间接洗钱工具新的一天从800个哈欠开始单亲妈妈陷入热恋 14岁儿子报警#春分立蛋大挑战#中国投资客涌入日本东京买房两大学生合买彩票中奖一人不认账新加坡主帅:唯一目标击败中国队月嫂回应掌掴婴儿是在赶虫子19岁小伙救下5人后溺亡 多方发声清明节放假3天调休1天张家界的山上“长”满了韩国人?开封王婆为何火了主播靠辱骂母亲走红被批捕封号代拍被何赛飞拿着魔杖追着打阿根廷将发行1万与2万面值的纸币库克现身上海为江西彩礼“减负”的“试婚人”因自嘲式简历走红的教授更新简介殡仪馆花卉高于市场价3倍还重复用网友称在豆瓣酱里吃出老鼠头315晚会后胖东来又人满为患了网友建议重庆地铁不准乘客携带菜筐特朗普谈“凯特王妃P图照”罗斯否认插足凯特王妃婚姻青海通报栏杆断裂小学生跌落住进ICU恒大被罚41.75亿到底怎么缴湖南一县政协主席疑涉刑案被控制茶百道就改标签日期致歉王树国3次鞠躬告别西交大师生张立群任西安交通大学校长杨倩无缘巴黎奥运

深圳SEO优化公司 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化