# I need a link for a guide to pushing to GitHub

**URL:** <https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088>\
**Category:** General\
**Created:** [October 9, 2021, 10:21pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088 "2021-10-09T22:21:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kernix](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kernix/32/223280_2.png) [@kernix](https://forum.freecodecamp.org/u/kernix)\
**Post date:** [October 9, 2021, 10:21pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/1 "2021-10-09T22:21:13Z")

</div>

I pushed to my repo last night using git bash. I was able to push a readme file I just created but not the other files that had changes. They are all marked with ‘m’.

How do you push updates to your repo? Here is what I did so far:

```auto
git status
git add filename
git commit -m 'message'
git checkout
- that didn't do anything
git push origin master
only added readme file
git commit -m 'new msg'
git push -u origin master
no changes added to commit (use "git add" and/or "git commit -a")
git commit -a 
- that messed up everything

pwd
git status
git push origin master

```

I got these messages in the terminal:

1. Your branch is up to date with ‘origin/master’.
2. no changes added to commit (use “git add” and/or “git commit -a”)

If you know of a GREAT blog post where all this is covered, that would be awesome!

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [October 10, 2021, 12:33am UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/2 "2021-10-10T00:33:15Z")

</div>

Hi @kernix !

> [@kernix](#):
>
> ```auto
> git checkout
> - that didn't do anything
> 
> ```

I use git checkout to go to other branches.  
So maybe that is not what you wanted to do here.

> [@kernix](#):
>
> ```auto
> git push origin master
> only added readme file
> 
> ```

It only added the readme file because of this line here

> [@kernix](#):
>
> `git add filename`

If you want to stage all of your files and you are in the current working directory you can use this

```auto
git add .

```

Here is an article on how to add all files

> **[Git: Add All Files to a Repo](https://stackabuse.com/git-add-all-files-to-a-repo/)**
>
> When you want Git to track a file in a repository, you must explicitly add it to the repo, which can become a bit cumbersome if you have many files. Another opt...

Usually what I do for pushing multiple files is the following.

```auto
git status
git add .
git commit -m "some commit message"
git push

```

This looks like a good article to read.

> **[How to Get Started with Version Control Using Git](https://www.freecodecamp.org/news/get-started-with-version-control-and-git/)**
>
> In this tutorial, you'll learn what version control is and how you can contribute to open-source projects using Git. We'll get through the fundamentals of Git and I'll give you the knowledge that is indispensable for any web developer. What is Git?...

FCC also has a course

> **[Git and GitHub Crash Course](https://www.freecodecamp.org/news/git-and-github-crash-course/)**
>
> Git and GitHub are used frequently by developers everywhere. These tools are used at most software companies and so they are important to understand if you want a job in the software industry. We've released a crash course video from Gwen Faraday...

Hope that helps!

---

<div class="post-metadata">

**Author:** ![kernix](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kernix/32/223280_2.png) [@kernix](https://forum.freecodecamp.org/u/kernix)\
**Post date:** [October 10, 2021, 1:06pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/3 "2021-10-10T13:06:11Z")

</div>

Thanks, let me check out those links and try the commands you listed. Will that work for all files changed after the initial commit? I was able to push the files from inside VS code but I didn’t know what I was doing there either. I would like to do it from git bash and from vs code without error each time. I also have a 1 hour+ long video from FCC in my YouTube watch later playlist. Thanks!

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [October 10, 2021, 1:15pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/4 "2021-10-10T13:15:00Z")

</div>

> [@kernix](#):
>
> Will that work for all files changed after the initial commit?

Whenever you make new changes you should be able to make new commits and push those to your repo on github.

I always use git status to see where I am at in the process.

---

<div class="post-metadata">

**Author:** ![anon58011934](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@anon58011934](https://forum.freecodecamp.org/u/anon58011934)\
**Post date:** [October 10, 2021, 1:42pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/5 "2021-10-10T13:42:05Z")

</div>

Hi,  
I found a couple of resources. They may come in handy.

> **[Git 07: Updating Your Repo by Setting Up a Remote | NSF NEON | Open Data to...](https://www.neonscience.org/resources/learning-hub/tutorials/git-setup-remote)**
>
> This tutorial covers how to set up a Central Repo as a remote to your local repo in order to update your local fork with updates. You want to do this every time before starting new edits in your local repo. Learning Objectives At the end of this...

> **[Pushing changes to GitHub - GitHub Docs](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/making-changes-in-a-branch/pushing-changes-to-github)**
>
> As you commit changes to your project locally, you can push those changes to GitHub so that others may access them from the remote repository.

This one is a 3 min video.

[![](https://img.youtube.com/vi/fAkVbjrEHI0/maxresdefault.jpg "git update repository") ](https://www.youtube.com/watch?v=fAkVbjrEHI0)

---

<div class="post-metadata">

**Author:** ![kernix](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kernix/32/223280_2.png) [@kernix](https://forum.freecodecamp.org/u/kernix)\
**Post date:** [October 10, 2021, 1:45pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/6 "2021-10-10T13:45:09Z")

</div>

Thanks, I’ll check them out!

---

<div class="post-metadata">

**Author:** ![kernix](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kernix/32/223280_2.png) [@kernix](https://forum.freecodecamp.org/u/kernix)\
**Post date:** [October 10, 2021, 1:46pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/7 "2021-10-10T13:46:45Z")

</div>

I tried the commands you provided and here is what I got:

```auto
git status
git add .
git commit -m "some commit message"
git push

 ! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/Kernix13/WriterAssist.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

```

Then I tried to do it fropm VS Code and the changes were gone but it didn’t push to my repo - let me read those docs and watch the video

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [October 10, 2021, 1:50pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/8 "2021-10-10T13:50:38Z")

</div>

Did you make changes directly on the GitHub repository itself and not pull those changes down locally?

If so, then you will need to do `git pull` to get those changes on your local machine before you can push the new changes.

Here is a stack overflow answer explaining it more.

> <https://stackoverflow.com/questions/24357108/git-updates-were-rejected-because-the-remote-contains-work-that-you-do-not-have>

---

<div class="post-metadata">

**Author:** ![DanCouper](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dancouper/32/158608_2.png) [@DanCouper](https://forum.freecodecamp.org/u/DanCouper)\
**Post date:** [October 10, 2021, 4:51pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/9 "2021-10-10T16:51:03Z")

</div>

So in order:

Check which files are staged for commit, and which have been committed:

```auto
git status

```

Stage **one** file to to committed:

```auto
git add filename

```

Commit anything in staging (so currently that one file) with a message attached:

```auto
git commit -m 'message'

```

Not really relevant here:

```auto
git checkout

```

Following isn’t quite true, if you ran `git status` again, whatever `filename` is would have moved from being listed as unstaged to being listed as commited:

```auto
- that didn't do anything

```

Push committed files. You committed one, so that’s what gets pushed:

```auto
git push origin master

```

Now nothing to commit, you haven’t added anything new:

```auto
git commit -m 'new msg'

```

Now nothing to push, you haven’t added or committed anything new:

```auto
git push -u origin master
no changes added to commit (use "git add" and/or "git commit -a")

```

Nothing to commit, you haven’t added anything new:

```auto
git commit -a 

```

Then you’ve done something, possibly reset everything? You now have a repo pushed up to GitHub with that one file, so:

Running this should have given you some information:

```auto
git status

```

Add all the files locally:

```auto
git add .

```

Commit everything that’s been added:

```auto
git commit -m "some commit message"

```

But you already have something on GitHub, and after whatever you did, GitHub is now possibly ahead of where you are now locally. As it is, I assume there’s just that one file, but git doesn’t know that it would actually be safe to override and push up everything even though there seems to be a duplicate. So when you do this:

```auto
git push

```

It fails, you need to `pull` the changes down from GitHub first, which will ensure you are up to date, then you can push safely

---

<div class="post-metadata">

**Author:** ![kernix](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kernix/32/223280_2.png) [@kernix](https://forum.freecodecamp.org/u/kernix)\
**Post date:** [October 14, 2021, 4:12pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/10 "2021-10-14T16:12:57Z")

</div>

So that is what I noticed in VS Code - you have to do pull them push. Why is that? I didn’t make any changes on github.

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [October 14, 2021, 4:17pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/11 "2021-10-14T16:17:15Z")

</div>

> [@kernix](#):
>
> ```auto
> error: failed to push some refs to 'https://github.com/Kernix13/WriterAssist.git'
> hint: Updates were rejected because the remote contains work that you do
> hint: not have locally. This is usually caused by another repository pushing
> hint: to the same ref. You may want to first integrate the remote changes
> hint: (e.g., 'git pull ...') before pushing again.
> hint: See the 'Note about fast-forwards' in 'git push --help' for details.
> 
> ```

This means that you had changes on the remote (GitHub) that you did not have locally (on your computer). Something changed between the two, somehow.

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [October 14, 2021, 4:50pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/12 "2021-10-14T16:50:45Z")

</div>

You have commits from two different users. I assume you are both of them?

If so you did change the README, maybe you did it directly from within GitHub which would make the README on the repo different than the one you have locally.

---

<div class="post-metadata">

**Author:** ![kernix](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kernix/32/223280_2.png) [@kernix](https://forum.freecodecamp.org/u/kernix)\
**Post date:** [October 14, 2021, 7:39pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/13 "2021-10-14T19:39:33Z")

</div>

Oh, I may have manually made changes to the README or contributing.md files while in GitHub.

---

<div class="post-metadata">

**Author:** ![astv99](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/astv99/32/66820_2.png) [@astv99](https://forum.freecodecamp.org/u/astv99)\
**Post date:** [October 15, 2021, 3:41am UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/14 "2021-10-15T03:41:47Z")

</div>

When you create a new repo on GitHub, the default README.md displays instructions on how to get started. After you follow those instructions, the typical Git commands you’ll use most often in sequence are:

git add   
git commit -m “message”  
git push

Generally you shouldn’t try to make modifications to files directly on [GitHub.com](http://GitHub.com). If you do have any changes on GitHub, `git pull` will “pull” it down to your local copy.

---

<div class="post-metadata">

**Author:** ![kernix](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kernix/32/223280_2.png) [@kernix](https://forum.freecodecamp.org/u/kernix)\
**Post date:** [October 15, 2021, 12:10pm UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/15 "2021-10-15T12:10:49Z")

</div>

Thanks. I’m still trying to learn these nuances or basics that I’m unfamiliar with. I started watching freeCodeCamp’s crash course on Git so hopefully, that will answer my questions.

---

<div class="post-metadata">

**Author:** ![elswise](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/elswise/32/229476_2.png) [@elswise](https://forum.freecodecamp.org/u/elswise)\
**Post date:** [October 21, 2021, 4:48am UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/16 "2021-10-21T04:48:59Z")

</div>

Did you come right with Git?  
Some Github repositories (all of mine) have main instead of master so push would be:  
git push origin main

---

<div class="post-metadata">

**Author:** ![kernix](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kernix/32/223280_2.png) [@kernix](https://forum.freecodecamp.org/u/kernix)\
**Post date:** [October 21, 2021, 11:18am UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/17 "2021-10-21T11:18:33Z")

</div>

I just looked at one of mine and it has ‘master’. But I was confused with the process in general: pushing for the first time with U/untracked files and then pushing for M/modified files. I watched a number of videos and took notes on their docs so now I have a good feel for the commands to use based on where I am in the process.

I haven’t done anything with creating branches since I am working alone on my repos. I would like to find a repo where the owner is open to contributors and see if I could learn the commands for branches. I play guitar and have a guitar chord based website so I searched and found some repos that have code to build SVG chords. I’m not sure how to contact the owners, but most of the ones I found haven’t been updated in years. I may have to create a 2nd GitHub account and try to do the branch thing from that account to my repos.

---

<div class="post-metadata">

**Author:** ![kernix](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kernix/32/223280_2.png) [@kernix](https://forum.freecodecamp.org/u/kernix)\
**Post date:** [October 21, 2021, 11:29am UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/18 "2021-10-21T11:29:36Z")

</div>

Of ‘main’ vs ‘master’, I’m condensing my notes and I have this as working under pushing new files:

> Initial push:  
> 0. git init | 1. git status | 2. git add -A or git add . | 3. git status | 4. git commit -m ‘notes’ | 5. git remote add origin url(from overview page) 6. git branch -M main (main or master)| 7. git push -u origin master |

I got that to work but should my #6 and 7 match with either ‘main’ for both or ‘master’ for both? All I know is that set of commands worked for me.

---

<div class="post-metadata">

**Author:** ![elswise](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/elswise/32/229476_2.png) [@elswise](https://forum.freecodecamp.org/u/elswise)\
**Post date:** [October 22, 2021, 5:40am UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/19 "2021-10-22T05:40:36Z")

</div>

From videos I watched, it seems Master was the default name for the Main in repositories. I don’t know if it is a new/ old thing or what. But whatever the Main ‘tree trunk’ is for your repository, that is what you use. Branches then Fork off the Main or Master - and Pull Requests (or Pushes from the remote side) merge back into the Main or Master, whichever the case may be.

What kind of person are you? My guess- you are a nice person, since you like coding and play guitar . . .  
I play keyboard, violin and guitar too.  
I have a private repository. It is a Household Budget I am writing in Python.  
I was going to do it all by myself, because it is specific to my requirements ( not for a client / I am my client ), but am considering opening it to certain people who are genuine, responsible, sensible, etc and won’t “mess it up” for a laugh. Are you interested?

---

<div class="post-metadata">

**Author:** ![astv99](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/astv99/32/66820_2.png) [@astv99](https://forum.freecodecamp.org/u/astv99)\
**Post date:** [October 22, 2021, 6:03am UTC](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088/20 "2021-10-22T06:03:39Z")

</div>

FYI, “git status” doesn’t effect any changes (it’s purely informational), whereas the other commands do effect a change. Keeping that in mind, this is a better order of commands:

1. git init
2. git remote add origin [git\_url]
3. git add [filename] (you can add a whole folder with “.”, or selectively choose individual files)
4. git commit -m ‘[commit\_message]’
5. git push

“git branch” is typically only needed when you’re creating a new branch, i.e. “git branch -b [branch\_name]”.  
“-u” on “git push” isn’t really necessary either, and can have unintended consequences  
“master” is now an outmoded name, and you can omit it anyway; Git will assume the main branch

Also on the subject of “master” vs “main”: [GitHub to replace "master" with alternative term to avoid slavery references | ZDNet](https://www.zdnet.com/article/github-to-replace-master-with-alternative-term-to-avoid-slavery-references/)

[Next page](https://forum.freecodecamp.org/t/i-need-a-link-for-a-guide-to-pushing-to-github/481088.md?page=2)
