How to share git branches that are based on same repository? - php

I am a novice programmer, and completely new to GitHub. I am collaborating with a colleague on a project he has been working on over the years.
So Far:
He created a repository and loaded up all the initial files. I forked it into my account, so that I could work on it separately.
Now:
How can I make a commit to my repository and share it with him, so that he can check out the changes and incorporate them into his repository IF he likes the changes?
I know there is a lot of information on GitHub, but I'm not even sure where to start. Any help is greatly appreciated.

Clone
Make Changes and Track it
Commit
Push to your github repo
Pull to your friends repo
Recommended approach in your case is collaborating with your friend.
Here is how:
Add a collaborator
Read this: Will give you basics of git and how to collaborate with others.

There are many ways to do this, github recommends pull requests and unless you have no push access to the repository you will need to do this or send patches. There is an example of such a workflow here
git clone git#github.com:<their repo> [optional folder name]
cd reponame (or optional folder name)
If the repository has submodules then
git submodule update --init (if the repo has submodules)
git submodule foreach 'git checkout <their working branch>'
Fork the code. Fork the specific repository you plan to work on. This will give you your own copy of the project. Set up git in the repository you plan to work on.
cd <repo dir or optional one chosen)
git remote set-url origin git#github.com:<your github name>/<your repo>.git
git remote add --track next upstream git://github.com/<their github name>/<their repo>.git
That is your repository set up to help with code. You can do git pull, git push, etc. (this will be to/from your fork). To pull in changes from a branch of the partner repo, just do:
git pull upstream branch
You will not be able to git push to their repo, for that you need to do a pull request.
When you are happy then go to github (your project) and select diff and pull request. This allows you to put in a message and the lib maintainer will get a message to attend to the request. It will also show if your pull request will merge cleanly, it is unlikely to be accepted if the maintainer has to fix code.

Related

Jenkins trying to delete the PHP project

We created a clone from the dev server for the jenkis CI to improve our work, we configurated it and the tests started working as we wanted. Then we find out that the git plugin in the jenkins is not liked with the project's workspace. It's a PHP REST api project, every server has it's own configuration. So we gave to the jenkins the path of the project to use that - this is the "Checkout to a sub-directiory" option. Then when a new PR is created, then jenkins is tiggered and it's start the build, and at first it's trying to delete the complete workspace.
I wouldn't think that it would be impossible to run tests on an already existing project with the jenkins, but this is ablosutly not the way how to do it. Every server has it's own configurations, so those are not part of the git repo, plus there is a base installation for the framework, and that's also not part of the git repository.
Now my question is what information are we missing, and how could we configure the git pluggin to make the jenkins start working on our existing project?
Ensure that you have the GitHub plugin and Git Pull Request Plugin installed in your jenkins workspace, now all you have check these 2 option
Also note that you have to add your public in Git which you would have done I'm guessing, now a hook will be created and you can send a request from Git and if you have a green tick ALL GOOD, else you have to debug it try this link Github webhook URL config issue? How to fix it?

How to set up a development environment using git for my wordpress website

I am developing a wordpress website and it is live. I am currently using file-zilla to update my code. Until now I wasn't in need of any version control, but now it seems that I need to manage a repository as well. We have also added two freelancers in a development team. So, it becomes difficult for us to manage development of this website.
I have read several blogs and I came to a decision that I will use Git for version control. However, I am struggling to find proper steps which explain to me about setting up a development environment for a team of freelancers. Also, I got a little information about bitbucket, but I am not sure if that is necessary for me. I am looking for the best answer to get started.
(Assuming you are leaving core Wordpress files alone and working only with themes and / or plugins as is best practice:)
Create a git repository every theme and plugin that you are working on using a server of your choice: I would go with Bitbucket for free private repos that you can invite the devs to.
Since you already have the files pushed by FileZilla, you would go into each of the folders for the themes and plugins you are using and push them as existing repos using SSH like so:
First initilize the repos and commit:
$git init
$git add .
$git commit -a -m "initial commit"
Then push
$git remote add origin git#bitbucket.org:my_org/my_repo.git
$git push -u origin --all # pushes up the repo and its refs for the first time
$git push -u origin --tags # pushes up any tags
If you are editing core files as well which would be highly discouraged, then you would create just one repo for the entire Wordpress folder, and then initialize, add, commit and push as above.
Development environments would be set up by the devs themselves using the platforms of their choice. Or ask them to use Vagrant if you want them to have similar environments.

Uploading an existing source to Bitbucket

Okay here's the overview. There's a Laravel 4.0 project in Bitbucket. I want to update this to version 4.1 so a Branch was created. I downloaded the Branch, but did not do the changes to that Branch. I kept is in a separate folder, downloaded a fresh new copy of Laravel 4.1 and moved the necessary files from the 4.0 Branch to the fresh 4.1 source. And changed the config settings as well.
Now I want to commit this fresh project back. Can someone please tell me if its possible to upload the fresh 4.1 project as a brand new Branch? If so how to do it?
I have downloaded the SourceTree as well. If you can tell me how to do it through the GUI, its even better. Either way is fine though.
Thank you.
use cherry-pick or rebase:
How to copy commits from one branch to another?
or rename your branch with:
git branch -m old_branch new_branch
and push this with:
git push origin your_branch_name -f
you can go to an existent branch and get your commits from another branch using git cherry-pick commit-hash-here, or if your changes are not commited, you can stash your changes using git stash and unstashing the changes in the other branch (executing git stash pop)
Are you asking for that?

Transfer existing website to git

I have a website which is written in php, jquery. I have just started a repository for it on github, and successfully copied a readme textfile to the site.
How do I (a) integrate the entire website into the git repository? Currently the project_git directory is at the same level as the httpdocs directory. How do I put it inside, but making sure that the website stays up and well?
(b) create a local repository which can push to this site?
Your help will be much appreciated.
Skip the README file for now and copy it.
Create an empty repository on github
git init in the folder where you want to track all your files, e.g. httpdocs
git add .
git commit -m 'first commit'
Add the repo on github as a remote, e.g. git remote add origin < githubpath >
Push up the master branch to github with git push origin master
Now you can add your README, commit and push, or do it in step 3
If you have pushed the README.txt file to github you are all set up (with a local repository). git will not mess with your current directory structure so it should be as easy as:
git add .
git commit -m "first commit of website"
git push origin master
And you should see everything in github
You'll need to provide us with a bit more insight into your file directory structure, and probably what platform you're on would be helpful.
Also note, if you just started a free github account, pushing your site up there will make the source publicly accessible. Just something to consider.
But basically, all you need to do to put the website into github is:
1) Navigate to the root directory of the site
2) Follow the directions on github for creating a bare git repo
3) Run git add ., git commit -m "Initial commit", git push
And you should be done! Especially if you've already pushed things to the site, you've already taken care of the RSA key setup and things :)

What is the recommended way for me to use git in my Lithium project?

After searching through many PHP frameworks to figure out which to learn and use, I've tentatively settled on Lithium. It looks great. Except, I'm not entirely sure how to best manage the Lithium apps I write in git, because of the recommended way of getting the code. The manual suggests:
git clone git://github.com/UnionOfRAD/framework.git my_app
cd my_app
git submodule init
git submodule update
This results in a non-empty main repository (2000+ commits in the history at present). Should I simply be committing my own changes within this same repository (in my own branches?) and pulling/merging when there are changes, or is there some other way that's recommended?
I know that I can also just download the files without cloning the repository, but since the manual indicates this is recommended I figured there must be a good reason and an ideal way of doing it. (I presume it makes it easier to update the framework when a new version comes out.)
It depends on your preferred setup.
If I want to quickly get rolling then a checkout of the example app works great. It has a bootstap config, example controllers and some views. But once you transcend that I suggest creating your own baseline app-repo and deploying the framework itself pr server and not pr app.
The app/config/bootstrap/libraries.php can easily be changed to load lithium itself from elsewhere.
So
Deploy lithium pr server (/home/lithium is my preference)
Create your own baseline app by copying the default li3 one and stripping/modifying it
Create a flexible vhost configuration so you can just git clone base-app ~/sites/foo-app, or similar, for quickly get rolling with a new app.
I have my (out-of-date by now) baseline app on github
Yes. In git you get a copy of all the history. You can track your work in your own branch and synchronize as you see fit using pull or fetch.
Since you are using github, fork that repo and clone from the fork. Should you want to contribute, you can create pull requests.
EDIT:
Initially, all you need to do is clone:
git clone <url to the repo>
git submodule --init --recursive
If you are not contributing, then the workflow is easy from then on:
git fetch
to fetch the latest from github
git merge --ff-only origin/master
git submodule update --recursive
If you get errors because you changed a file by accident, you can
git reset --hard HEAD
git clean -xdf
and start with the merge step again. You may need to go into the submodule directories and do the above 2 steps there if the changes happened there.
Hope this helps.

Categories