Pergunta

I have a bash script that does the following:

  1. Clones a repo;
  2. Modifies some files;
  3. Commits the changes;
  4. Pushes the commits to repo's default branch.

Now, if I clone a repo with git clone <repo> I assume the default branch of the repo is cloned locally. If I push the commits with git push, is it 100% sure that the commits will be pushed to repo's default branch? I don't want to specify to which branch to push to (e.g.: git push origin master) because the script will be generic and repos will have various default branch names.

If some of my assumptions are wrong, please point me to the right direction.

Foi útil?

Solução

By default, git uses the branch called "master". So when you clone a repository, you will be in master branch. After doing changes, you can push your commits without declaring the branch name. Git pushes to the master branch of remote repository.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top