Doubts regarding push to remote repo

Hi Team,

I have cloned a forked repo using the URL of the forked repo & navigate to the master branch of the cloned repo.

After navigating inside the cloned repo project, I make some changes & commit the changes in the master branch of the cloned repo.

I now intend to push the changes to the forked remote repo.

As I push, I use the alias ‘origin’.

Does git figure out that it has to push the changes to the forked repo & not to the original repo?

I ask this because in Q:7 of Fork Lab, ‘origin’ was used to push the changes to remote repo. ‘origin’ was the alias of the original repo, I believe

When you clone a repository, that repository is configured as the only remote repository under the name origin. On the location where you cloned the repo, Git has no idea that this repository was ever forked from somewhere, so it will never push to the original repository.

If you want to find out where git is going to push to, you can check the url for the remote repository with git remote -v. Besides that, you can also specify to which remote and branch you want to push by using git push <remote_repo_name> <remote_branch_name>.

Thank you v.much for the detailed explanation.

1 Like