View previous topic :: View next topic |
Author |
Message |
colt n00b
Joined: 17 Apr 2018 Posts: 16 Location: são paulo
|
Posted: Tue Apr 17, 2018 10:41 pm Post subject: git push stopped working |
|
|
Hello, I had to delete the working directory of a project. It should have not been a problem, since I expected to clone it from my repository on gitlab and then start working on it again.
And I did it, but when I tried to push a new commit back to gitlab, I received: Code: |
error: The requested URL returned error: 401 while accessing https://gitlab.com/..../.....git/info/refs
fatal: HTTP request failed
|
I updated my git and tried again to issue a [quote]git push origin[/quode]. the new git asks for my repo address on gitlab and I gave it:
Code: | git push -u origin......
Username for 'gitlab.com';: gitlab.com/asmf2/asmfrt.git
Password for 'https://gitlab.com/asmf2/asmfrt.git@gitlab.com';:
[remote: HTTP Basic: Access denied fatal: Authentication failed for 'gitlab.com/asmf2/asmfrt.git/'; |
I then entered my password for the gitlab website. I also tried "git config --global push.default" after that and then repeated all above without success.
Is the the password that I use to login on gitlab the same that I shall enter on here? If no, what can be the problem? Thanks for your time.
Edited: I also tried to enter instead of Quote: | https://gitlab.com/asmf2/asmfrt.git | and enter a null password (just pressed enter) and they did not worked.
[Moderator edit: changed block [quote] tags to [code] tags to preserve output layout. Inline [quote] tags left as-is. -Hu] |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Tue Apr 17, 2018 11:39 pm Post subject: |
|
|
That remote URL looks totally wrong, usernames should not go near the end. The semicolons in the output look highly suspicious too. Do this to fix it:
Code: | git remote set-url origin git@gitlab.com:asmf2/asmfrt.git |
|
|
Back to top |
|
|
1clue Advocate
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Wed Apr 18, 2018 12:21 am Post subject: |
|
|
FWIW I've never had luck committing when the project was checked out with http. Are you sure you didn't check it out the first time using ssh?
Try checking out using ssh, and use an rsa key as authentication. |
|
Back to top |
|
|
colt n00b
Joined: 17 Apr 2018 Posts: 16 Location: são paulo
|
Posted: Wed Apr 18, 2018 9:48 pm Post subject: |
|
|
Ant P. wrote: | That remote URL looks totally wrong, usernames should not go near the end. The semicolons in the output look highly suspicious too. Do this to fix it:
Code: | git remote set-url origin git@gitlab.com:asmf2/asmfrt.git |
|
I copied and pasted your Code: | git remote set-url origin git@gitlab.com:asmf2/asmfrt.git |
then I entered and received: Code: | ssh: Could not resolve hostname git\357\273\277lab.com: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists. |
Quote: | Try checking out using ssh, and use an rsa key as authentication. |
I think I am checking out using ssh now that I executed what Ant P. told me to do. What would be the use of the rsa key?
Mod edit: [code] tags added for clarity. — JRG |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Wed Apr 18, 2018 10:09 pm Post subject: |
|
|
Hmm. There's no publicly viewable project on Gitlab (gitlab.com) named asmfrt, so that's a potential problem. Do you have a private commercial arrangement with them?
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
ct85711 Veteran
Joined: 27 Sep 2005 Posts: 1791
|
Posted: Wed Apr 18, 2018 11:25 pm Post subject: |
|
|
@John, doing a quick search, I did find the asmfrt repo on gitlab; the full name is asmfrt2 (author being asmf). As far as the address in the most recent posts, is correct as what gitlab says (for both https and ssh), and cloning works for me using the https address (did not try pushing anything).
https://gitlab.com/asmf2/asmfrt |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Thu Apr 19, 2018 1:04 am Post subject: |
|
|
Okay, I figured out what I was doing wrong. Successfully cloned, too, via ssh. Thanks very much for pointing out my mistake.
@colt, check your git configuration. Here's what I have: Code: | $ git config --list
user.name=John R. Graham
user.email=john_r_graham@gentoo.org
core.pager=less -x1,5
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@gitlab.com:asmf2/asmfrt.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master | - John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
colt n00b
Joined: 17 Apr 2018 Posts: 16 Location: são paulo
|
Posted: Thu Apr 19, 2018 11:25 pm Post subject: |
|
|
Here is: Code: | git config --list
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@gitlab.com:asmf2/asmfrt.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
|
P.S: While I don't solve the issue, if I keep making new commits, the future push will send all of them to gitlab, right (I think so, but just to be sure)
P.S.2: If I try to do the push from another directory, where there is a branch of it, I receive Code: | To git@gitlab.com:asmf2/asmfrt.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@gitlab.com:asmf2/asmfrt.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details. |
So perhaps is something related to the local dir?
[Moderator edit: changed [quote] tags to [code] tags to preserve output layout. -Hu] |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21633
|
Posted: Fri Apr 20, 2018 1:48 am Post subject: |
|
|
Each locally stored repository is independently configured. You could have two local clones, one configured correctly and one configured incorrectly. Is your latest git config --list output from the non-working clone? What error message is produced when you try to push from that clone? (I see that upthread you provided an error message, but I want to be sure that subsequent changes have not invalidated that message.)
Yes, local commits are kept until you delete all references to them (and even then, they are only removed during repository cleanup). Yes, if you fix your configuration to allow publishing, then you can publish commits made before you fixed your configuration. |
|
Back to top |
|
|
colt n00b
Joined: 17 Apr 2018 Posts: 16 Location: são paulo
|
Posted: Fri Apr 20, 2018 6:48 pm Post subject: |
|
|
From the "master", the one that I referred initially and that I wish to push to gitlab: Code: | git config --list
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=git@gitlab.com:asmf2/asmfrt.git
branch.master.remote=origin
branch.master.merge=refs/heads/master |
Code: | git push origin
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
ssh: Could not resolve hostname git\357\273\277lab.com: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
|
From the branch that I use only locally:
Code: | git config --list
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@gitlab.com:asmf2/asmfrt.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
|
Code: | git push origin
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
To git@gitlab.com:asmf2/asmfrt.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@gitlab.com:asmf2/asmfrt.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details. |
I can notice that these lines: Code: | remote.origin.url=git@gitlab.com:asmf2/asmfrt.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* | are swapped
[Moderator edit: changed [quote] tags to [code] tags to preserve output layout. -Hu] |
|
Back to top |
|
|
ct85711 Veteran
Joined: 27 Sep 2005 Posts: 1791
|
Posted: Fri Apr 20, 2018 8:20 pm Post subject: |
|
|
Quote: | ssh: Could not resolve hostname git\357\273\277lab.com: Name or service not known |
This is looking like an issue relating to encoding. Anymore, git defaults to using UTF-8 encoding on anything it uses; but I suspect your default charset is not a UTF-8 compatible one. What is the output of
https://wiki.gentoo.org/wiki/UTF-8 |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21633
|
Posted: Sat Apr 21, 2018 12:19 am Post subject: |
|
|
Normally, I chastise people who repeatedly use incorrect markup, requiring me to correct post after post. In this case, it's actually convenient that you got it wrong. While fixing your markup, I noticed you have an errant character in your configuration. (Though, to be fair, I thought to look for it because of the phrasing of the error message, so I might have caught it even if you had used the correct markup.) It is invisible in the forum, but smarter text editors show it.
Good configuration: Code: | remote.origin.url=git@gitlab.com:asmf2/asmfrt.git | Bad configuration: Code: | remote.origin.url=git@gitlab.com:asmf2/asmfrt.git | See the difference? In Firefox, they look the same, but are not actually the same. In a real text editor, you'll see that there is an errant 0xfeff between git and lab in the domain gitlab. Fix your origin.url line and try again. If you cannot see the errant character in your text editor, I suggest getting a better text editor. Vim and GVim both show it. |
|
Back to top |
|
|
colt n00b
Joined: 17 Apr 2018 Posts: 16 Location: são paulo
|
Posted: Sat Apr 21, 2018 9:34 pm Post subject: |
|
|
Thanks Hu, I wasn't using any text editor, I just copied the output of from the terminal.
I opened the config file with two text editors, nano and gedit and none was able to show the character. I then used "less" to read it, and it showed. Then I proceeded to erase the line and copied and pasted the line from the git dir that seemed work. Finally send a and worked.
Can I ask what is this character and why only some editors shows it? How can have it ended there? |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21633
|
Posted: Sat Apr 21, 2018 11:08 pm Post subject: |
|
|
According to Wikipedia, that is a Byte Order Mark (BOM). All editors should show it, at least when it is not at the start of the file, but arguably even then. I don't know why both of your preferred editors failed to show it. It got there because you put it there, likely by pasting from some source which had it. Since it seems to be invisible in browsers too, you probably didn't realize it was there when you copied it from a webpage. Since your editors also fail to show it, you didn't see it after you pasted it, either. Looking back, it looks like you probably got it by copying from Ant P.'s post. Indeed, checking that post in a text editor shows that the bad character is hiding in there. So then the question becomes, where did he get that text and how did it get into his post? |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Sat Apr 21, 2018 11:33 pm Post subject: |
|
|
Ehh... I stuck it in manually to stop the forums automatically turning that text into an invalid link. Didn't think it'd come through copy+paste, but that just reinforces the point that you shouldn't blindly copy and paste random commands off the internet.
Whoops. |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21633
|
Posted: Sun Apr 22, 2018 12:37 am Post subject: |
|
|
Indeed. When I need to inhibit matching, I use a zero-length formatting directive (bold, italic, underline - whichever is not busy in the text at the time). This issue reminds me of LWN: A look at terminal emulators, part 1, which discussed in part some of the amazingly bad things browsers do to make pasting into terminals even more dangerous than people might expect. Among other things, there are sneaky ways to include arbitrary text in the selection that does not render on screen, such as: Code: | <html><body>rm -i <span style="position:absolute;top:-1000em"> -f -r /*</span> /tmp/obsolete</body></html> | On screen, it renders as rm -i /tmp/obsolete. When copied, it yields rm -i -f -r /* /tmp/obsolete. |
|
Back to top |
|
|
|