Do I need to run "add" and "commit" before I "push" changes to upstream (making a PR)?

5.1k Views Asked by At

At the bottom there are contribution rules of a project in GitHub. Particularly step 4 is under the question. It doesn't say anything if I need to run add and commit commands before I run git push --set-upstream.

Because when I have made my changes, I get modified and untracked files in my local repo. So do I need to add and commit them before git push --set-upstream?

enter image description here

  1. Fork the Material-UI repository on Github
  2. Clone your fork to your local machine git clone --depth 1 [email protected]:<yourname>/material-ui.git (For the next branch, add the -b next flag to the above command.)
  3. Create a branch git checkout -b my-topic-branch
  4. Make your changes, lint, then push to github with git push --set-upstream origin my-topic-branch.
  5. Visit github and make your pull request.
2

There are 2 best solutions below

0
On

Yes, you do need add and commit your changes before pushing your code to your github repository.

0
On

Since you have to add and commit your changes (in a new pr branch you just created), don't forget also to check your user.name/user.email.
Check the output of:

git config user.name
git config user.email

Those have nothing to do with your GitHub account but will be the visible information attached to the commit you will push. Make sure they are right before your commit.

See "Setting your username in Git"