I have published my local angular v13 project to github remote. While pushing the repo to remote I was given instruction from git like to do these commands:
git branch -M master
git push -u origin master
I would like to know what does these commands do, and why my repo was not reflecting with any files until I use the above mentioned commands.
CodePudding user response:
Based on git documentation https://git-scm.com/docs/git-branch
git branch -M master
renames your current branch to master
, thus keeping a standard for git.
Up until this point, your repository on github is not aware of anything. You need to visualize your local git repository as a directory on your machine and github repository as a backup directory on another entirely different machine. If you create a file on your local directory, the only way to sync these two different directories is for you to copy this file onto the remote's directory.
git enables you to do this using commands. So if you want to move files/changes from your local to github (remote) you need git push
and if you want to move files/changes from github (remote) to local, then you need git pull
.
Since you are working on your local directory and the github repository is empty, then you need to push
to move your changes.
git push -u origin master
tells git to move all your local changes to github on a branch named master. That's is why you'll only see your files after the git push command.