I'm new to github. I started with
git remote add origin URL
This linked my local files with the github account. I then did:
git push -u origin master
This copied my files to github
I then proceeded to make some changes to my .py file in the local repository and then saved it. I did this to test the commit push feature. Next I typed:
git add.
git status
git commit -m "Q1 solution"
git push
The code pushed to github but I am not sure if I did it correctly. Youtube videos are all saying I should have done git push origin (the alias-ed URL). Do I need to do this or is git push enough once you've done the initial setup with:
git push -u origin master
Edit:
git status
gives me:
On branch master
Your branch is up to date with 'origin/master'.
Not sure what this means origin/master?!?
Thanks,
CodePudding user response:
The -u
option to git push
means:
-u
--set-upstream
For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull and other commands.
So from that point on, running git push
by itself is the same as running git push origin master
-- in both cases, you are saying "push my master
branch to the master
branch of the remote named origin
".
When you see the message:
Your branch is up to date with 'origin/master'.
This means you have already synchronized your local branch with the remote branch.
CodePudding user response:
My friend you pushed it correctly to the master branch
when we use :
git push
it's pushed automatically to the repo and into the branch where you are which is the master branch
when should I use the full hand version?
git push [alias] [branch]
git push origin main/master
we use this one when we want to push our changes to another branch
and you can
create a branch in git
git branch [name]
then you want to make changes in just this branch you should stage it
git checkout [name of the branch]
and you can add or commit without changing anything in the other branches
check this cheat sheet https://education.github.com/git-cheat-sheet-education.pdf