Can't pull student repos
Describe the bug
I cannot pull updates in students assignment using gh classroom pull student-repos -a ... command. It says:
failed to run gh: can't sync because there are diverging changes; use `--force` to overwrite the destination branch
. error: exit status 1
however, there are no diverging changes. It also does not work when there are no updates, as shown here:
$ gh classroom clone student-repos
? Select a classroom: XXXX
? Select an assignment: YYYY
Creating directory: /ZZZZ-submissions
Cloning into: /ZZZZ-submissions/ZZZ-AAA
Cloning into: /ZZZZ-submissions/ZZZ-BBB
Cloned 2 repos.
$ gh classroom pull student-repos
? Select a classroom: XXXX
? Select an assignment: YYYY
Pulling repo: /ZZZZ-submissions/ZZZ-AAA
failed to run gh: can't sync because there are diverging changes; use `--force` to overwrite the destination branch
. error: exit status 1
Pulling repo: /ZZZZ-submissions/ZZZ-BBBB
failed to run gh: can't sync because there are diverging changes; use `--force` to overwrite the destination branch
. error: exit status 1
$ gh --version
gh version 2.52.0 (2024-07-15)
https://github.com/cli/cli/releases/tag/v2.52.0
$ gh extension list
NAME REPO VERSION
gh act nektos/gh-act v0.2.55
gh classroom github/gh-classroom v0.1.14
Steps to reproduce the behavior
- Clone students repositories using
gh classroom clone .... - (Optional) Modify the reference repository and request Pull Request, accept it.
- Try to pull repository again
Expected vs actual behaviour
I would expect all repositories to be updated. Now I need to update them manually, which works ok (no diverging changes).
Logs
Paste the activity from your command line. Redact if needed.
$GH_DEBUG=true gh classroom pull student-repos -a AAAAAA
* Request at 2024-07-23 13:35:52.177507471 +0200 CEST m=+0.028484741
* Request to https://api.github.com/assignments/AAAAAA
* Request took 414.42728ms
Pulling repo: XXXXXX
failed to run gh: [git remote -v]
[git config --get-regexp ^remote\..*\.gh-resolved$]
[git remote -v]
[git config --get-regexp ^remote\..*\.gh-resolved$]
* Request at 2024-07-23 13:35:52.616066256 +0200 CEST m=+0.020500993
* Request to https://api.github.com/graphql
* Request took 295.087327ms
[git -c credential.helper= -c credential.helper=!"/usr/bin/gh" auth git-credential fetch -q upstream refs/heads/master]
[git rev-parse --verify refs/heads/master]
[git merge-base --is-ancestor master FETCH_HEAD]
can't sync because there are diverging changes; use `--force` to overwrite the destination branch
. error: exit status 1
The command was executed in the same directory where gh classroom clone student-repos --all was executed before.
Thanks for opening this issue, rlalik. I'm also experiencing the same issues for Github Classroom.
same here, same error message ...Easy to reproduce, just clone a repo or an assignment and try to pull :
gh classroom clone student-repos
gh classroom pull student-repos
Ditto. I'm having the same issue.
I'm glad I still have my old Python scripts... they are compatible with gh classroom but not as convenient - I have to manually add projects to a config class.txt file where 'class' is the name of a class and download the corresponding roster CSVs.
I just dusted it off and it ran as expected on the previously gh classroom cloned repos.
- The
get_repos.txtfile describes the usage. - I've included a sample class config file,
4u.txt, for a formatting example - The script expects all your class projects to be in the same parent directory (described in your class config file) and for your
classroom.csvfile to be in that directory as well. - Also works with group projects and the appropriate
csvfile for the groups. - If you don't use
~\Documentsor~/documentsas your base directory, you can change it in thecommon_ui.pyfile. - Save the scripts wherever you like... the project directories are declared in the scripts and class config files.
Sample folder structure, based on the example in 4u.txt plus common_ui.py (base_dir = ~/Documents):
Documents
`--ics4u
`---24-01
|---oop1-sommatif-submissions
| `---student repos from this script or from 'gh classroom clone student-repos'
`---classroom.csv
These are personal scripts and I haven't added a licence. Use at your own risk and do whatever you like with them if you do.
Could it have something to do with fetching upstream (starter repo) as well as origin during pulls? For the students' work we only need the updates to origin unless I am missing something.
I'm still getting the OP's original error message:
I cannot pull updates in students assignment using
gh classroom pull student-repos -a ...command. It says:failed to run gh: can't sync because there are diverging changes; use `--force` to overwrite the destination branch . error: exit status 1
A much simpler iteration through the assignment directories in the x-submissions folder with the command git pull origin main works as expected though.
Can I request a feature? It would be to add a flag to the classroom pull command, like -o, to specifiy pulling from origin only, ignoring upstream. This would be practical for getting students' changes only.