开发者

What's the git equivalent of this Mercurial action to initialize and upload a repo?

开发者 https://www.devze.com 2023-04-11 05:08 出处:网络
In Mercurial, I usually do this: hg init hg addremove hg commit -m \"init repo\" hg push https://arezzo:mypassword@bitbucket.org/arezzo/mynewrepo

In Mercurial, I usually do this:

hg init
hg addremove
hg commit -m "init repo"
hg push https://arezzo:mypassword@bitbucket.org/arezzo/mynewrepo

I tried something similar in git and it didn't work:

git init .
git add .
git commit -m "init repo"
git push https://arezzo:mypassword@bitbucket.org/arezzo/mynewrep开发者_如何学编程o

The message I get after push is:

Everything up-to-date

Nothing gets pushed to bitbucket.


When you don't specify a branch to push when you're using git push, it by default will only push branches where a branch with the same name exists in the remote repository. In this case, I guess that this is the first time that you're pushing to this repository, so there is no branch called master yet - thus, git push URL doesn't push anything.

Another tip that may be useful is that you usually create a remote as a short name for the repository URL when you're using git. So, to modify your steps slightly, try the following instead:

mkdir mynewrepo
cd mynewrepo

git init
git add .
git commit -m "Initial commit"
git remote add origin https://arezzo:mypassword@bitbucket.org/arezzo/mynewrepo
git push -u origin master

Then you can use origin in place of the URL. You only need to use the -u option the first time that you push - it just sets up some helpful default config options so that git pull works without additional arguments, for instance.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号