开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜