0

My requirement is to pull and push files only for particular folder from the master repo. The method I am using is only helping me in pulling files for particular folder but not in pushing.

So in my master repo I have folder structure something like below.

mainfolder
  examfold1
  examfold2
  examfold3

this is what i am doing.

git clone http://123456@onestash-test.com/mainfolder
cd mainfolder
git config core.sparseCheckout true
echo examfold3/*> .git/info/sparse-checkout

this is working fine when i pull, it doesn't bring files on other folders but it also not bringing files for examfold3 and i get below error when i push after making some files changes from local repo.

! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'http://123456@onestash-test.com/mainfolder'
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 believe git is thinking my local repo is not sync with master because i didn't pull files for other folder. Any help will be really appreciated. Thanks in advance.

rohit rawat
  • 1
  • 1
  • 4
  • What does `git status` show? AFAIK a sparse checkout does not affect pulls/pushes, it just affects which files are checked out into your working directory. – David Deutsch Jun 11 '15 at 15:30
  • On branch master Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch) nothing to commit, working directory clean – rohit rawat Jun 11 '15 at 15:39
  • And after you do a `git pull`, is the `git status` the same? – David Deutsch Jun 11 '15 at 15:48
  • * branch master -> FETCH_HEAD Updating 71dd862..04ce809 error: Sparse checkout leaves no entry on working directory – rohit rawat Jun 11 '15 at 15:58
  • 1
    Hmm... does http://stackoverflow.com/questions/23289006/on-windows-git-error-sparse-checkout-leaves-no-entry-on-the-working-directory help? – David Deutsch Jun 11 '15 at 16:02

0 Answers0