6

I'm trying git clone and push in a docker file. I have succeed to clone git repository with a Personal Access token like mentioned in this link Cannot clone git from Azure DevOps using PAT.

But I could not achieve make git push with using PAT to our company repositories. The below code working for clone git config --global http.extraheader "AUTHORIZATION: Basic VXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX3Xx" git clone --depth 1 http://tfsXXX/tfs/XXXXX/XXXXGIT/_git/XXXXXXX

Could Someone help me How I can achive git push with PAT?

captainblack
  • 903
  • 3
  • 9
  • 20

2 Answers2

2

As I mentioned here, you can try and use your PAT as user: http://PAT@tfs2017:8080/tfs

Or keep your AUTHORIZATION: Basic header, but, as mentioned there, do base64 encode your PAT.

Note that http.extraheader might work better with Git 2.25 (Q1 2020).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hello firstly thank you reply. I have achived clone repository with PAT like your mention. But I could not push with PAT. Is there special syntax for Basic authentication PAT for push process. I trid many syntax but I could not achive.Tried something like git -c http.extraheader="AUTHORIZATION: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" push --set-upstream http://XXXXXXXXXXXXXXXXXXXX@tfsmaster/tfs/defaultconn/DGIT/_git/Myproject master – captainblack Apr 08 '19 at 06:28
  • @user3820266 If it is a public repository, the clone would work with no authentication anyway, so that step alone is not conclusive. On the push front, repeating the PAT (both in extra header and URL) should not be needed: try one or the other separately. – VonC Apr 08 '19 at 06:33
0

I was able to get through this error by ensuring that my token had full repo access. I did a simple git push, without header switches. When prompting for my password, I used the PAT and successfully pushed to my repo.