0

When I execute this command:

$  git remote -v

result:

origin  https://ShafizadehSajad@bitbucket.org/ShafizadehSajad/test.git (fetch)
origin  https://ShafizadehSajad@bitbucket.org/ShafizadehSajad/test.git (push)

When I execute this command:

$ git push -u origin --all 
/* or even this one:
 * $ git push -4 origin master
 */

result:

// it waits for a while an throws this:
fatal: unable to access 'https://ShafizadehSajad@bitbucket.org/ShafizadehSajad/test.git/': Failed to connect to bitbucket.org port 443: Timed out

When I execute this command:

$ ping -n 10 bitbucket.org

result:

Pinging bitbucket.org [104.192.143.2] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 104.192.143.2:
    Packets: Sent = 10, Received = 0, Lost = 10 (100% loss),

Well as you see, I cannot connect to bitbucket and apply changes. What's the problem? And how can I fix it?

Notes:

  1. I use windows 8 OS
  2. This current repo on bitbucket been a repo on github that I use it in bitbucket. When I was on github, it works as well.

EDIT:

And I've executed this command right now:

$ git config --local http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

and now, when I execute this:

$ git push -u origin --all

result is:

fatal: unable to access 'https://ShafizadehSajad@bitbucket.org/ShafizadehSajad/test.git/': Couldn't resolve proxy 'proxy.server.com'

Heh .. it got worse. At least tell me how can I back it to the previous situation?

Community
  • 1
  • 1
stack
  • 8,752
  • 9
  • 54
  • 91
  • I have edited my answer. Can I ask a moderator to delete all the comments below? They have been recorded in a chat session anyway. (http://chat.stackoverflow.com/rooms/131781/discussion-on-answer-by-vonc-reporting-problems-to-access-bitbucket) – VonC Dec 29 '16 at 13:20

1 Answers1

2

General solution

There is no incident reported on BitBucket side or on twitter or on isitdownrightnow, so it is an issue on your side.

Switching to an ssh url would not help much since bitbucket.org is not reachable anyway.

Check if your firewall prevents somehow bitbucket.org access.

See more in my previous answer "Failed to connect to bitbucket.org port 443: Network is unreachable"

  • Check if your previous successful push to github.com needed a proxy.
  • Check if your DNS settings have changed (explaining why your proxy is not resolved)

Specific solution

After discussion, the OP stack can browse bitbucket.org only through a proxy (psiphon, see also this article or this one).
This proxy does not require authentication, but should be configured to run always on the same port in order for Git to use it. For instance, port 61234 (provided the port is not already used)

Making sure this proxy is used only for bitbucket.org is simple since Git 1.8.5 (2013).
Type, from any folder you want:

git config --global http."https://<username>@bitbucket.org".proxy http://localhost:61234

In your case:

git config --global http."https://ShafizadehSajad@bitbucket.org".proxy http://localhost:61234

That will modify your global Git setting (recorded in C:\Users\<You>\.gitconfig), and will apply those settings for any local repo you will create or already have.

To test an access to a remote Git repo without even having to clone it, use git ls-remote:

cd /path/to/local/repo
git remote -v
  origin https://ShafizadehSajad@bitbucket.org
git ls-remote origin

Since March 2015 and Git 2.7.3, Git for Windows comes with a Git Credential Manager for Windows which allows Git to cache passwords using the native Windows Credential Store: if you type git config credential.helper, you should see "manager".
At the first connection to bitbucket.org (like during a git ls-remote, done for testing access), you will be prompted for your bitbucket credentials (ie, ShafizadehSajad + bitbucket password). The next connections will reuse those credentials.
Open your credentials store with Control Panel, go to User Accounts and Family Safety -> Credential Manager: you will see a bitbucket.org entry.

Once a git ls-remote is working (and don't ask for your password, since it has been cached in the Windows Credential Store), a git push might fail because the remote repo was never fetched into the local one.

For that, first make sure a git pull will always rebase. Type, from any folder (and only once, since it is a global config)

git config --global pull.rebase true
git config --global rebase.autoStash true

(Those global settings are valid since Git 2.6, Sept. 2015)

Then, to fetch your remote bitbucket repo:

cd /path/to/local/repo
git fetch
git branch -u origin/master master

You need to make sure the local master branch is tracking the remote tracking origin/master branch which was just fetched.
See more at "Why do I need to explicitly push a new branch?".

Finally, pull first, since some commits were done directly on BitBucket, while others were done locally on the PC:

Before rebase:
x--x--x (master)
o--o    (origin/master)

git status:
(2 behind, 3 ahead)

After pull (which does here a fetch+rebase)
o--o--x'--x'--x' (master)
   |
 (origin/master)

The rebase has replayed your local 'x' commits on top of the fetched remote commits 'o'.

Now you are ready to push:

git push

Everything should be visible on bitbucket.org.

o--o--x'--x'--x' (master, origin/master)

(and github.com should not be affected, meaning a git ls-remote https://github.com/sajadshafizadeh/test.git should still work)

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • Ok, I will take a look at the link you provided about *firewall* .. Just have you seen edited version of my question? I mean I need to return everything to the previous situation *(lack of proxy in config)* first .. Do you know how can I do that? – stack Dec 28 '16 at 08:34
  • @stack First, check that pushing to or cloning from github.com still work. Check your environment variables (for any `HTTP(S)_PROXY` variable). Check your full `git config -l` output. – VonC Dec 28 '16 at 08:36
  • You know, I'm pretty much newbie in `git` and I think I cannot do your suggestions. Thank you anyway, upvote – stack Dec 28 '16 at 08:37
  • Well I'm trying to go back to github by this `$ git remote set-url origin git clone https://github.com/sajadshafizadeh/test.git`. But it says: https://i.stack.imgur.com/cwJVJ.png .. Do you know what's wrong? – stack Dec 28 '16 at 08:42
  • 1
    Correction: `git remote set-url origin https://github.com/sajadshafizadeh/test.git` – Sajib Khan Dec 28 '16 at 08:44
  • @stack I assumed that `proxyuser:proxypwd@proxy.server.com` was a generic value to avoid revealing your actual user password and proxy server setting. But your picture shows precisely that in the output of `git config -l`: I confirm you won't be able to resolve proxy.server.com. You can unset it all (http://stackoverflow.com/a/11500903/6309) – VonC Dec 28 '16 at 08:47
  • Do you want a TeamViewer session for me to see what is going on? – VonC Dec 28 '16 at 08:48
  • Ok well, I've unset that proxy by using `$ git config --local http.proxy'` and then I could connect to github and apply the changes, I mean my files updated on github ..! [All fine](https://i.stack.imgur.com/kxs1h.png) ..! Now I need to do the same for bitbucket. Any idea? – stack Dec 28 '16 at 08:51
  • @stack make sure you have an empty Git repo ready on bitbucket.org. See if ping -n github.com is working, and, as I suggested in http://stackoverflow.com/a/38606704/6309, check if pinging bitbucket.org works (in IPV4 or IPV6) – VonC Dec 28 '16 at 08:55
  • may sound silly, but try to clone again (use the url on the bitbucket repository page), and push something just for testing. if it works, it's because something in this (your 1st) clone is broken. And you can even try with other bitbucket repo – pedrorijo91 Dec 28 '16 at 08:56
  • @VonC Yes, this is my id `104 594 506`. Just there is three points: 1) I don't know English very well. 2) bitbucket website is blocked in my country, so I have to use a proxy to open it *(currently I use Psiphon)*. 3) the internet speed is slow in my country, so sometimes you need to wait a bit. Ok? – stack Dec 28 '16 at 16:18
  • @stack Trying to connect now. So far, this doesn't seem to work. "No connection to partner:Partner did not connect to router. Error Code: WaitforConnectFailed". – VonC Dec 28 '16 at 16:21
  • @stack progress! It is asking me for a password. Have you set one? If so, what is the password for this TeamViewer session? – VonC Dec 28 '16 at 16:27
  • @VonC Thank you very much for updating your answer, and it seems useful. Also I've tried to configure the git based on the script you provided .. but I failed kinda because of being really unfamiliar with command line environment. Thank you anyway sir `:-)` – stack Dec 29 '16 at 09:21
  • @stack no problem. Let me know when I can try to set it up for you. If you can browse bitbucket.org, you should be able to push to that server, provided the proxy is set correctly. – VonC Dec 29 '16 at 09:22
  • @VonC Yes, I totally got your point .. as I can browse bitbucket.org via proxy, then if I apply the same configuration for the git, I will be able to connect to that server ..! Also can you please connect to my computer *(via teamviewer)* right now? Really embarrassed for asking this, but I really stuck on this problem, I'm not a cheeky person. – stack Dec 29 '16 at 09:29
  • @stack the password must have changed. Do you have anew one? – VonC Dec 29 '16 at 09:39
  • Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackoverflow.com/rooms/131781/discussion-on-answer-by-vonc-reporting-problems-to-access-bitbucket). – Bhargav Rao Dec 29 '16 at 10:23
  • @VonC One question, You constantly have insisted "change your password" ... Ok, which password do you mean exactly? bitbucket? teamviewer? – stack Dec 30 '16 at 08:04
  • 1
    @stack I meant the one used by the proxy. But it turned out... psiphon does *not* require authentication, so you did not have to type in clear text any login/password in your proxy url: it was `http://localhost:`. I did not see your BitBucket password: you typed and cached it in the Windows Credential Store. And sure, you can change your TeamViewer password. – VonC Dec 30 '16 at 08:07
  • How are you man? Apparently what you have configured is gone .. I've tried to config it again o by myself *(based on updated version of your answer)*, but still it doesn't connect to bitbucket. See [this](https://i.stack.imgur.com/cqnkJ.png) plesae. Do you know what's the problem? *(noted that stack and I are working on the same project)* – Shafizadeh Dec 31 '16 at 17:07
  • @Shafizadeh my answer refers to a dummy port number 61234 (just as an example). But you need to use the same port as the one we configured in your psiphon settings. I remember having modified those settings in order for psiphon to *always* use the *same* port number. – VonC Dec 31 '16 at 17:15
  • @VonC I see, I've set the right port to the git's configuration ... now the error got changed .. [any idea?](https://i.stack.imgur.com/lwJtd.png) – Shafizadeh Dec 31 '16 at 17:29
  • @Shafizadeh yes, a simple `git pull` will do. Then `git push`. – VonC Dec 31 '16 at 17:36
  • @VonC Great .. it's done successfully ..! Just one short questions: why `git pull origin master` works as well for me but just `git pull` doesn't? – Shafizadeh Dec 31 '16 at 17:43
  • 1
    @Shafizadeh maybe because your local master branch was not tracking origin/master. See my answer above: that is what `git branch -u origin/master master` would do. – VonC Dec 31 '16 at 17:44
  • You know, I'm a curious person kinda and I love to know a bit more about some people. You have **lots** of knowledges about programming and computers, But you've never been proud. May you please tell me what's secret of being that much adorable? Are you following a particular *(famous)* person? – Shafizadeh Jan 04 '17 at 17:44
  • @Shafizadeh Thank you for your kind words. As you can see in https://stackoverflow.com/cv/vonc, I am an IT support guy, so this (my daily activity on Stack Overflow) is not about ego or fame, just about honing one's craft: daily practice. Every day (http://meta.stackexchange.com/q/122976/6309). That is the secret. – VonC Jan 04 '17 at 19:12
  • I do follow from time to time Jon Skeet, of course. But in my fields, I follow torek (http://stackoverflow.com/users/1256452/torek), icza (http://stackoverflow.com/users/1705598/icza), Jonathan Leffler (http://stackoverflow.com/users/15168/jonathan-leffler) or Brian Cowan (http://stackoverflow.com/users/4223401/brian-cowan), all far more knowledgeable that I am. – VonC Jan 04 '17 at 19:15
  • *"just about honing one's craft"* -- well great ideology it is! But where does it come from? What about your own job?! Do you even have any? What's your income? *(answering to this is optional)* .... btw, seriously? are you following [Brian Cowan](http://stackoverflow.com/users/4223401/brian-cowan), he doesn't have even 1k rep! I guess you pointed him wrongly ;-) – Shafizadeh Jan 04 '17 at 19:27
  • 1
    @Shafizadeh "What about your own job?!": that is what https://stackoverflow.com/cv/vonc is supposed to illustrate: my job is IT support, which aligns neatly with the kind of support I can provide here. – VonC Jan 04 '17 at 19:28
  • 1
    "are you following Brian Cowan, he doesn't have even 1k rep! I guess you pointed him wrongly ;-)": reputation is merely of reflection of the participation on Stack Overflow. It does not reflect on expertise. Every answer Brian made on ClearCase impressed me, hence I follow him. I follow expertise, not shinny karma points on a Q&A site. – VonC Jan 04 '17 at 19:30