0

So I'm trying to pull a branch from one of my private repositories into GitHub Actions, so I can modify it and push it back into that repository, but it won't let me. Although I can clone the repo, but since I need to push modified files back into the repository, that won't work. The workflow that I ran the commands on, runs on ubuntu-latest. Another thing to note is that when I ran these same commands on my Windows computer, everything runs properly, but for some reason, I didn't need the token or username for the link to work. When I try to pull from the remote repo, I get the following error.

remote: Repository not found.
fatal: repository 'https://github.com/[username]/[repo].git/' not found
Error: Process completed with exit code 1.

But when I try to clone the repository, the command successfully runs. The commands I ran are below.

I create the remote repo with

git remote add repo https://[username]:[token]@github.com/[username]/[repo].git

The token has the repo scope, so it has complete access to repositories. To verify that the command worked, I ran

git remote -v

Which shows the new remote that I added so I know it worked. Next I try to pull the master branch from the remote repo with

git pull repo master --allow-unrelated-histories

Which is where I get the error. The clone command is

git clone https://[username]:[token]@github.com/[username]/[repo].git

This command runs successfully unlike the git pull command.

I have looked at Git - remote: Repository not found and Git Clone - Repository not found, but none of the answers I've tried helped me. Since the commands worked on my local computer, it most likely isn't the commands, and is probably something to do with how GitHub Actions runs the commands or the token.

What I did for the problem to occur

  1. Create a private repository.
  2. Add files, commit, push, etc.
  3. Create a public repository.
  4. Add a workflow file.
  5. Create a personal access token with the repo scope.
  6. Add a secret in the public repo and set it to https://[username]:[token]@github.com/[username]/[private repo].git
  7. Add the commands git remote add repo ${{ secrets.[secret name] }}, git remote -v # To verify that the remote add worked, git pull repo [main/master branch], and ls
  8. commit and push the workflow file and then run the workflow.
  9. Open the session log to see the error
randomuser922
  • 147
  • 12
  • After the `git clone`, does `git pull` work correctly in the local repository? – larsks Feb 24 '21 at 20:30
  • 1
    don't want to be rude.. but I hope in square brackets is something real without square brackets – Moris Finkel Feb 24 '21 at 20:30
  • 1
    @MorisFinkel yes it is. – randomuser922 Feb 24 '21 at 20:32
  • @larsks on my computer, I ran the `clone` command, then the `pull` command. The clone worked, but the pull said it refused to merge unrelated histories, which is different from what I got earlier (it was not caused by the clone command as I ran into this before i ran it). On github actions, the pull command didn't work no matter what. – randomuser922 Feb 24 '21 at 20:37
  • Try to check this one https://stackoverflow.com/questions/849308/pull-push-from-multiple-remote-locations ```git remote update``` – Moris Finkel Feb 24 '21 at 20:37
  • 1
    The "unrelated histories" error really suggests that there's more going on here than you're showing us in the question. If you can start from scratch (that is, remove or rename the local directory) and then update your question with the exact sequence of steps that results in the error, that would help us help you. – larsks Feb 24 '21 at 20:39
  • @larsks The repository I am working in, was brand new and the command stopped working around the first commit. – randomuser922 Feb 24 '21 at 20:43
  • 1
    @MorisFinkel I tried `git remote update` but it gave the same error with another line that says `error: could not fetch repo`. – randomuser922 Feb 24 '21 at 20:48
  • @larsks I fixed the `refused to merge unrelated histories` error by adding `--allow-unrelated-histories` to the command, it works perfectly for what I'm doing. Sadly, I still need an answer to the queston. – randomuser922 Feb 24 '21 at 22:51
  • Sounds to me like something is very broken, but without a complete reproducer I'm not sure what it is. If you'd like to update your question with a specific sequence of steps that demonstrates the problem (ideally in a way that I can reproduce it on my computer) I'm happy to take a look. – larsks Feb 24 '21 at 22:52
  • @larsks I added a "What I did for the problem to occur" section, hopefully that is enough. – randomuser922 Feb 24 '21 at 23:48
  • Please add the complete workflow definition file to your post. Are you using the `checkout` action because this persists the default token that is read-only. – riQQ Feb 26 '21 at 23:16

1 Answers1

0

I fixed my problem by setting the .git/config file to what my local .git/config file was, and that solved the problem. I don't know what part of the config file was causing the error, but I do know there was a problem with it.

randomuser922
  • 147
  • 12