Git submodules without head disconnected?

I may not use git -submodules specifically, but if there is any other git function that suits my case, it would be nice to find it.

After cloning the repository, I want the submodule to be in the main branch, I will never store any additional files inside the sub-module of the chef starter.

git clone git@github.com:holms/vagrant-starter.git
git submodule update --init
cd chef-starter
git branch
   * (detached from 0b6a803)
   master

I understand that this is a good function to track this submodule tree separately, but this is not my case. After the main repository cloning, I just want this submodule to be cloned to the latest master studio without any additional problems.

How can i achieve this?

+3
source share
3 answers

, " ". master ( , commit 0b6a803), Git .

git-submodule . , git submodule update --remote :

# Add the submodule with the "master" branch referenced
git submodule add -b master https://github.com/holms/chef-starter.git chef-starter

# When you want to update the submodule:
git submodule update --remote

# You'll still need to commit the submodule if you want future checkouts to use the new revision
git add chef-starter
git commit -m "Update chef-starter submodule"

, (vagarant-starter), .

git -subtree :

# First, get rid of the submodule
git submodule deinit chef-starter # If you have Git 1.8.3 or later, otherwise edit .gitmodules
git rm chef-starter               # Remove the directory
git commit -m "Removed chef-starter submodule in preparation to add as a subtree"

# Now add the subtree
git subtree add -P chef-starter https://github.com/holms/chef-starter master --squash

chef-starter chef-starter/ vagrant-starter. , . , git submodule update .

+7

, . - , , . .

git pull
git submodule sync    # Ensure the submodule points to the right place
git submodule update  # Update the submodule  
git submodule foreach git checkout master  # Ensure subs are on master branch
git submodule foreach git pull origin master # Pull the latest master
+2

:

1) -b :

git submodule add -b master git@github.com:Bla-bla/submodule.git sm_dir

2) -merge CURRENT ( , master):

git submodule update --merge

0

All Articles