Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with git config pull.rebase false #106

Closed
AnnikaLau opened this issue Apr 4, 2024 · 3 comments · Fixed by #108
Closed

Issue with git config pull.rebase false #106

AnnikaLau opened this issue Apr 4, 2024 · 3 comments · Fixed by #108
Labels
beginner Relevant for Beginner's course

Comments

@AnnikaLau
Copy link
Contributor

AnnikaLau commented Apr 4, 2024

The following leads to an error being in Exercise_6

# source the helpers.sh file to be able to use its functions
source ../helpers.sh
# init exercise
init_exercise

# Set up remote Git repository
init_repo_remote
git remote add my_remote ../conference_planning_remote
git fetch my_remote

# Create merge conflict with remote
git switch updated_schedules
# Change first event in _schedule_day1.txt_ to "Introduction talk"
git add schedule_day1.txt
git commit -m "Introduction talk"
# Run helper function to commit to the same file remotely
commit_to_remote_by_third_party

# Choose your preferred way of pulling
git config pull.rebase false
git pull
git restore schedule_day1.txt --theirs # or "git restore schedule_day1.txt --ours"
git add schedule_day1.txt
git commit -m "Take remote version"
# Now the local branch is ahead of 'my_remote/updated_schedules' by 2 commits.
git push

The last command leads to the following error message:

Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 516 bytes | 516.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0), pack-reused 0
remote: error: refusing to update checked out branch: refs/heads/updated_schedules
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote: 
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote: 
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ../conference_planning_remote
 ! [remote rejected] updated_schedules -> updated_schedules (branch is currently checked out)
error: failed to push some refs to '../conference_planning_remote'

How would one do this correctly?

@AnnikaLau AnnikaLau added the beginner Relevant for Beginner's course label Apr 4, 2024
@AnnikaLau
Copy link
Contributor Author

@mjaehn can you have a look at this?

@mjaehn
Copy link
Contributor

mjaehn commented Apr 8, 2024

Is this still a problem? Or everything okay as stated in #105?

@AnnikaLau
Copy link
Contributor Author

Is this still a problem? Or everything okay as stated in #105?

It is still a problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginner Relevant for Beginner's course
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants