How to pull and push sub directory in Git

1.2k views Asked by At

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://[email protected]/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://[email protected]/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.

0

There are 0 answers