0

I've created a local git repo, which contains 2 branches i.e master and stable
Using master as a development branch and it has gone 4-5 commits ahead of stable and it also contains some unstaged edits.

The problem is that a bug has come in against stable, so I've stashed my unstaged edits on master and performed a checkout against stable. Now I need a file from master, specifically travis.yml, so I can add it to stable for when I commit the bug fix.

Is there a clean way to do this so that when I merge stable back into master there are no conflicts with the existing travis.yml?

This is what I've tried but no luck ..

rob@laptop:~/git/project$ git status
On branch stable
Your branch is up-to-date with 'origin/stable'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   config/user.properties

no changes added to commit (use "git add" and/or "git commit -a")

rob@laptop:~/git/project$ git checkout master/86e6e26acf .travis.yml
error: pathspec 'master/86e6e26acf' did not match any file(s) known to git.
error: pathspec '.travis.yml' did not match any file(s) known to git.
bobbyrne01
  • 6,295
  • 19
  • 80
  • 150
  • So you are going to merge your stable branch into the development branch? – Bartlomiej Lewandowski Oct 15 '14 at 13:19
  • so after bug fix are you expecting "travis.yml" to be same across master and stable? – Ajay Oct 15 '14 at 13:32
  • Error seems pretty self explanatory, `pathspec master/...` doesn't exist. I'm pretty sure the command you're looking for is `git checkout master -- .travis.yml`. There's a related question here: [Meaning of Git checkout double dashes](http://stackoverflow.com/questions/13321458/meaning-of-git-checkout-double-dashes). – Roman Oct 15 '14 at 13:34
  • @R0MANARMY your suggestion is what worked for me, your welcome to create an answer and ill accept – bobbyrne01 Oct 20 '14 at 21:05

2 Answers2

0

So after bug fix are you expecting "travis.yml" to be same across master and stable? In that case easy way would be checkout the master, copy the contents of travis.yaml into a temp location, checkout stable replace travis.yaml in stable with the one you had saved.

Git is intelligent enough to identify that both the files are same and not to show any merge conflicts. Infact git will only store a single file for both the branches. I hope this helps.

Ajay
  • 2,976
  • 2
  • 28
  • 35
  • 1
    Git lets you check out individual files from other branches, so that's probably an easier path than switching branches and copying file into a temp location. – Roman Oct 15 '14 at 13:39
0

@R0MANARMY answer worked for me ..

"Error seems pretty self explanatory, pathspec master/... doesn't exist. I'm pretty sure the command you're looking for is git checkout master -- .travis.yml. There's a related question here: Meaning of Git checkout double dashes."

Community
  • 1
  • 1
bobbyrne01
  • 6,295
  • 19
  • 80
  • 150