I've created several private repos that I'm working on through Laravel 4.2's workbench feature.
How do I get composer to also install/update all the git submodules in the workbench dir on the production server when it updates the vendor dir for the main project?
Why you force composer to do that ?.
I guess you have following project pattern.
Project - A that have many private repo (submodules). for eg: you can add a blog module(Individual Private repo) as submodule to the Project - A .
like
git submodule add path_to_private_repo_for_blog workbench/Vendor_folder/blog.
Once you created all the individual repo as submodule like above. then you can get update using following command.
git pull && git submodule foreach git pull origin master
so simply you can update and deploy the Project -A with following command.
git pull && git submodule foreach git pull origin master && git add -A && git commit -m 'updated pakages' && git push && envoy run update
hope it make sense..
Related
Here is what im try to achieve, I have a laravel app with a BitBucket repo in my laravel project public directory (public/repo.name).
Now what i want is to run, git add . git commit -m "Changes" and git push from my (public/repo.name) directory inside my laravel app.
I want the git commands to run when i go to lets say, http://127.0.0.1:8000/deploy this would only deploy whatever changes are in (public/repo.name)
Convert your Project to a Git Project
Open your terminal and navigate to the project root directory and run the git init command.
git init
git-init-laravel-project
Git init Laravel project
Git Add and Commit All Files
With the git init command we have successfully converted our project into a local git project. Although we have not yet added a git remote to our project.
As a second step lets go ahead and add and commit all the files to our local git repository.
Run the git add and git commit command on the project root.
git add .
git commit -m "First Commit"
The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit.
The git commit command commits the staged snapshot to the project history. Committed snapshots can be thought of as “safe” versions of a project—Git will never change them unless you explicitly ask it to.
Git add and Git commit on Laravel project
Create a New BitBucket Repository
We are now ready to push our changes to a remote repository. But before that we have to create a repository where we can push our changes.
Login to Bitbucket if you already have an account or SignUp for a new account. On the left hand menu , Click on the + symbol to get the option of Creating a New Repository.
Create Bitbucket empty Repo for Laravel.
Enter a suitable project name and click on Create Repository. A blank repository will be created and you will be redirected to the overview page of the repo.
Now we can go ahead and make this repo our remote repo for the Laravel project.
Add Remote Repo and Push Changes
To add the repository you just created as the remote repo for your local Laravel project. Run the following command on your project root in terminal.
git remote add origin https://<repo_owner>#bitbucket.org/<accountname>/<reponame>.git
Replace the repo_owner and accountname in the URL accordingly.
git-laravel-remote-add
git remote add laravel
Now we can go ahead and push the changes to remote repository.
git push -u origin master
git-laravel-push-bitbucket
Git push Laravel project
If you see at source in your bitbucket repository. You should see your Laravel directory structure along with the files.
I want to create a new empty repository with git. I cannot find a simple solution online that explains this step.
This documentation states "git-init - Create an empty Git repository or reinitialize an existing one" but then doesn't say which options are needed to make it empty:
https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-init.html
Is a --bare repository the same as an empty repository?
Problem:
I have two different projects with different repo's on github, but when I try to use Git (in Bash) after changing the directory to the new project, it keeps pushing with files from the old project.
I think the problem is that git is using the old repo files and thinks the new folder is just additional files perhaps? Basically I want to start from fresh. Can I just start from scratch on my new project with a new repo?
I have tried $ git init in a new directory, but then it just says: "Reinitialized existing Git repository in /home/user/new_project/.git/"
I tried: $ git remote set-url origin git#github.com:User/New_Project.git
but that just updates where it pushes my new project to, and then includes old projects files.
Please help a noob trying to figure things out the hard way 🙏🏼
Delete .git folder:
rm -rf .git
Then create new git repository:
git init
git remote add origin <remote-URL>
git add .
git commit -m "new clean repo"
git push --force origin master
create 1st project
make git init
create a remote repo for 1st project
link remote repo to 1st project
create 2nd project
make git init
create a remote repo for 2nd project
link remote repo to 2nd project
Git will push everything to its proper remote repo
Small hint from my side
git init : create empty repository and reinitialize an existing one
following link will give more information about different options can be used during git init ($GIT_DIR)
https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-init.html
I'm currently having an issue with my git submodule. I've created a git submodule in my cloned project folder and it appears right on my repo. But when I click on the symlink, it gives me Error 404 page not found. I am VS Code and Windows 8 x64. Thanks a lot for your help! Below is what is written in the .gitmodules
[submodule "themes/casper-two"]
path = themes/casper-two
url = "https://github.com/eueung/hugo-casper-two"
I cannot find the caa182b commit in the hugo-casper-two repository, so I believe you need to update the submodule to the latest commit available. To do this, run the following command from your project directory:
git submodule foreach git pull origin master
This command will update every submodule in your project and pull the latest commit from their master branch.
Remember to commit your own repository afterwards.
git commit -am "Pulled down updates to submodules"
How to specify branch in .gitlab-ci.yml for a submodule (different repo) in gitlab-ci?
You don't. You specify it in the .gitmodules file of the project you are building.
[submodule "MyRepo"]
path = MyRepo
url = https://github.com/vendor/MyRepo.git
branch = master
Along with #stefan's answer to this question. You also have to tell Git to only look at the specified branch for the latest commit. git submodule update seems to always fetch the latest commit regardless of the branch. Doing git submodule update --remote seems to force git to focus on the branch you specify in the .gitmodules file.
So in your .gitmodules files, as #stefen mentions:
[submodule "MyRepo"]
path = MyRepo
url = https://github.com/vendor/MyRepo.git
branch = master
Then in your GitLab .gitlab-ci.yml file, you need to specify to only look at the configured branch when setting up submodules. My file includes this before_script:
# GitLab CI provides a variable "GIT_SUBMODULE_STRATEGY" that sets up submodules automatically
# But then branch tracking doesn't work (doesn't seem to allow for specifying the --remote) flag
before_script:
- git submodule sync --recursive
- git submodule update --init --remote --recursive
According to documentation, this before_script is the same functionality as provided by GIT_SUBMODULE_STRATEGY (except that I can add the --remote flag to the before_script): https://docs.gitlab.com/ee/ci/yaml/README.html#git-submodule-strategy
so I just installed a new remote git repository on one of our servers and want to move our old projects there. Our existing projects have local git repositories, and we can add repos from the server, but how do we move our existing projects onto the server?
Any ideas?
You would do these steps:
Make the individual repositories on the server.
git clone --bare nameofrepo
On the actual repo, add the remote to the repository from which you want to send up work:
git remote add origin <url to your remote>
Now push your branch for your work:
git push origin master
Repeat for any other branches you want to have pushed to the central repo.
The URL in the first command can also be a regular file path. Most solutions, however are through an SSH connection.
After creating your Xcode project, cd to that directory
and make sure you are on the master branch
Type:
git remote add origin <URL-of-your-GitHub-repository>
git pull
git branch --set-upstream-to=origin/master master
git merge
git commit -m "Merging with remote”
git push
Now your new project has been pushed to the remote GitHub directory.