0

I am new to Git. I have recently created a repository and uploaded a folder in it using the following sequence of commands:

$ git init
$ git add <file name>
$ git commit -m "some comment"
$ git branch -M main
$ git remote add origin <url>
$ git push -u origin main

This was my first time when I uploaded the files to this repository. Now I am trying to upload more files to this repository using the following commands:

$ git add <file name>
$ git commit -m "some comment"
$ git branch -M main
$ git push -u origin main

But, I am getting the following information:

Branch 'main' set up to track remote branch 'main' from 'origin'.
Everything up-to-date

Why is it so? How can I upload more files on my repository using git in the command line?
Please resolve it.
Thank you!

UJM
  • 167
  • 8
  • Hi please check answer https://stackoverflow.com/questions/1184518/getting-existing-git-branches-to-track-remote-branches – Zaur May 20 '21 at 11:58
  • 1
    In general, you should only do the `git branch -M main` *once*, when you first create the repository. And, in general, once you have run `git push -u origin main` *once*, you do not need the `-u` here any more. You will need it for *other* branch names, *once per branch name*. The real problem was that you forgot to commit, though, as you found and noted under the accepted answer. – torek May 21 '21 at 00:08

1 Answers1

1

I am not sure what is causing you're specific problem here, but i think you are not following the correct workflow. These are the steps you should follow:

  1. Type git branch and ensure that you are on the main branch (if not do git checkout main)

  2. Then do:

    git add <file>
    git commit -m "comment"
    git push -u origin main
    

Follow this flow everytime you want to push to this branch and you should have no issues.

Joshua Zeltser
  • 488
  • 2
  • 9