I need a link for a guide to pushing to GitHub

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:

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!

Hi @kernix !

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

It only added the readme file because of this line here

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

git add .

Here is an article on how to add all files

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

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

This looks like a good article to read.

FCC also has a course

Hope that helps!

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!

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.

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

https://www.neonscience.org/resources/learning-hub/tutorials/git-setup-remote

This one is a 3 min video.

Thanks, I’ll check them out!

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

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

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.

So in order:

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

git status

Stage one file to to committed:

git add filename

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

git commit -m 'message'

Not really relevant here:

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:

- that didn't do anything

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

git push origin master

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

git commit -m 'new msg'

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

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:

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:

git status

Add all the files locally:

git add .

Commit everything that’s been added:

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:

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

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.

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.

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.

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

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. If you do have any changes on GitHub, git pull will “pull” it down to your local copy.

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.