title: How to push to remote with the rust git2 crate
body: <p>I'm trying to push my git repository using git2. I can't seem to get it right. Here's my code:</p>
  <pre class="lang-rust prettyprint-override"><code>pub fn push(repo: Repository) -&gt; Result&lt;(), git2::Error&gt; {
      let mut opts = PushOptions::default();
      let mut callbacks = RemoteCallbacks::new();
      callbacks.credentials(|_url, _username_from_url, _allowed_types| {
          println!(&quot;Cred input callback has been called&quot;);
          let password: String = scanpw!(&quot;Password for 'https://CrazyVideoGamer@github.com': &quot;);
          Cred::userpass_plaintext(&quot;CrazyVideoGamer&quot;, &amp;password)
      });
      opts.remote_callbacks(callbacks);
      repo.find_remote(&quot;origin&quot;)?
          .push::&lt;&amp;str&gt;(&amp;[], Some(&amp;mut opts))
  }
  </code></pre>
  <p><code>scanpw!</code> simply prompts me for my password. But for some reason, when I try to run this code, it always asks me for my password over and over again. Why isn't this working?</p>
  <p>Here's the gif of me trying to input my password:
  <a href="https://drive.google.com/file/d/13CfOsabotma1LSsqGuyCwxQTKJrvBnKx/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/13CfOsabotma1LSsqGuyCwxQTKJrvBnKx/view?usp=sharing</a></p>