GIT Updating subree: how can I update my subtree?

We have a few repo’s like :

Site1:

  • Dropbox and Git working together
  • How can I track a git repository in a different directory?
  • Git: fatal: Needed a single revision even though repo/revision both supplied
  • Git server side hook not firing - how to check
  • Git and Visual Studio: How to work with remote repo?
  • Where does git rebase make changes
    • lib:

    Site2:

    • lib:

    lib:

    As you see lib is shared in both sites. Now when I use

    [master] git fetch lib
    

    Nothing happens.
    After that I use :

    [master] git merge --squash -s subtree --no-commit lib
    

    Then it starts deleting loads of files that belongs to the site.

    If I try this:
    Update the Library Sub-Project from the Shared Library Remote
    http://www.codeproject.com/Articles/562950/GitplusSubtreeplusMergeplus-e2-80-93TheplusQuickpl

    [master] git checkout lib
    Checking out files: 100% (4521/4521), done.
    Switched to branch 'lib'
    [lib] git pull
    Already up-to-date.
    

    Then just checkout to the master, and run the command:

    git merge --squash -s subtree --no-commit lib
    

    This just deletes a whole load of files from my site and leaves a few files like its in a subfolder of lib..
    Why doesen’t this just update the lib to the correct version? and leave the files for the site?

    After a reset I do get my project back

    git reset --hard origin/master
    

    How can I update the lib?

    There is a remote branch setup.

    $ git remote -v
    lib     https://github.com/***/lib.git (fetch)
    lib     https://github.com/***/lib.git (push)
    

  • WARNING: Your version of git is 1.9.3. has serious security vulnerabilities
  • Travis-ci: Watch and build a single branch from a Git remote repository
  • Git checkout <commit> and then commit and retain all commits
  • Using git filters to ignore a specific line in json file
  • My Git Pull/Push records from different account
  • SSL certificate: Invalid certificate chain
  • One Solution collect form web for “GIT Updating subree: how can I update my subtree?”

    Considering that you already set your subtree in your app (git remote add subtree_name git@github.com:user/subtree_proj.git) your have to:

    1- Subtree split

    git subtree split -P lib -b new_branch_to_split where the lib is the path to your subtree project and the new_branch_to_split will only contain your lib code and will be pushed to your lib repo.

    2- Subtree push

    git push subtree_name new_branch_to_split:original_subtree_branch(i.e. master)

    or

    git push subtree_name new_branch_to_split:master

    3- Always delete the temporary branch

    git branch -D new_branch_to_split

    4- Pull the changes in your other project that’s using the subtree project

    git subtree pull -P lib subtree_name original_subtree_branch(i.e. master)

    Git Baby is a git and github fan, let's start git clone.