0

I am currently having an issue with a branch which had files that were listed as untracked in git.

This branch was sent for review and it came back with saying that the files that were moved were deleted. I checked it and the files were listed as untracked even though when I changed to the branch on my local pc I could navigate to these files. Maybe it's still in my cache, I don't know.

The reviewer made some changes then pushed to my branch and passed it back to me. I then did a git add "filename" for the untracked files. I then committed them, did a push and it said I need to do a pull. So I proceeded and did the pull and it brought up another message "There is no tracking information for the current branch. Please specify which branch you want to merge with".

I did git branch --set-upstream-to origin UXUI-805 and then it said "Branch UXUI-805 set up to track remote branch master from origin". Should'nt it be set up to track the current branch that I am on instead? because initially I need to push to work to the same branch but the one that is the remote branch on the repo.

Furthermore, I did a git branch to check which branch I was on and I was still on the same branch "UXUI-805"

Went ahead with git pull => and it said the branch was up to date then tried to do a pit push to origin UXUI-805. It rejected the push and I got this message

hint: Updates were rejected because the tip of your current branch is behind 
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I tried git status and it said

On branch UXUI-805
Your branch is ahead of 'origin/master' by 32 commits.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean

Tried a git stash but that said there is no work to save. This is because I've already committed the work

I don't know how to fix this. Please help. Thanks

chuckx
  • 6,484
  • 1
  • 22
  • 23
Jukebox82
  • 41
  • 9
  • It might help to document the output of `git branch -r` and `git remote -v` (scrubbing the repository names if you don't want to publicly share them of course). – chuckx Jun 04 '18 at 06:20
  • `git pull origin xxx` would avoid such pains. `git pull origin -r xxx` would avoid more. `xxx` is the branch you want to pull. – ElpieKay Jun 04 '18 at 06:29
  • Possible duplicate of [How to resolve git error: "Updates were rejected because the tip of your current branch is behind"](https://stackoverflow.com/questions/22532943/how-to-resolve-git-error-updates-were-rejected-because-the-tip-of-your-current) – phd Jun 04 '18 at 09:48

1 Answers1

0

You have a simple case of master branch on server and private branch on your PC. If you wish to merge to master on server, you need a single commit on top of master, send for review and merge. To do that, check out your latest commit, do git reset --soft origin/master. You'll get the master latest + your changes ready for commit.

Adashi
  • 461
  • 1
  • 4
  • 8