Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push only for bare repositories?

When I tried 'git push origin master' to remote repository on my external disk, git warning occured stating that pusing to checkout repository will in next releases of git refused by default. On external disk I have checkouted project and I want to send changes that I did on my computer to these reposiotry. Is 'git push origin master' not the right way? Do I have to 'git pull ...' on repository on my external disk? So I cannot push changes but just pull them? Only working with 'bare' repository is different? So if repository on my external disk was a bare repository I could push changes to it? Do I understand correcly?

like image 224
miki Avatar asked Jan 27 '10 14:01

miki


People also ask

Can you git push without committing?

No, you must make a commit before you can push. What is being pushed is the commit (or commits).

Can I push to someone else's repository?

Using the command lineAdd a connection to your friend's version of the github repository, if you haven't already. Pull his/her changes. Push them back to your github repository. The pull request on github will be automatically closed.

Does git push push to all remotes?

The objective is to push to multiple Git remotes with a single git push command. If you don't want to create an extra remote named all , you can skip the first command and use the remote origin instead of all in the subsequent command(s). Now, you can push to all remote repositories with a single command!


1 Answers

Read the warning carefully. The new default prohibition is only on pushing to the currently checked out branch in a non-bare repository. It is perfectly OK to push to any other branch in a non-bare repository.

The reason for this is that the push process has no direct access to the working tree so the index and branch head get changed under the working tree. When you subsequently go to the working tree it looks like working tree has undone the changes pushed mixed in with any changes that were genuinely in development. This makes it very difficult to separate the two sets of changes.

Pushing to other branches has no such downsides. You can then go to that repository and merge those changes into the checked out branch if desired.

like image 114
CB Bailey Avatar answered Sep 20 '22 23:09

CB Bailey