I have two branches one for developing and other for staging. I first checkout the developing branch and then build some files on it and then checkouts staging branch and push the new files to staging
git checkout develop
#
# Run some build scripts here
#
git fetch origin staging:staging
git checkout staging
git add *
git commit -m "new commits"
but its giving this error
error: Untracked working tree file * would be overwritten by checkout.
file.1
file.2
file.3
file.1 and file.2 and file.3 doesn't exist in develop branch but it creates after the build script runs and it also exists in staging.
I tried multiple ways to solve this problem. I tried force checking out git checkout --force staging but it exits with nothing to update message. Then I tried this
git fetch origin staging:staging
git stash
git reset --hard
git checkout staging
git add --all
git commit -m "new commits"
which also fails
ERROR
Auto-merging newfile.xx
CONFLICT (add/add): Merge conflict in newfile.xx
On branch staging
Unmerged paths:
(use "git restore --staged <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both added: newfile.xx