0

I'm a total newbie to this Git.

My PHP project files have been added to Git by admin.

Now one new person is going to start working on this project. He will work on one module of this project. So, being a senior developer I've been asked to create a branch for him that will contain only specific files that he will need to start work on the specific module.

So this thing has created so many questions in my mind :

  1. Can I create a special branch for him with only specific/selected files from the project? If yes, how? If no, why?
  2. Now only master branch of project is present. If the new branch of git is created for the new developer and he commits and pushes the changes he made to the git; how will they get merged with the master branch? Do I need to do it manually using third party tool like 'DeployHQ' or anything like or is there any way around.
  3. To keep the things easy for him what I want to do is he should be able to commit, push the changes, those changes would straight away be reflected on server and he should be able to check it by running the pages in a browser. Can I make the this simple and easy as I'm thinking.

In a nutshell I don't want to disclose all of my project files to him and want to keep things easier and simpler for me as well as for him.

Please please please guide me.

Thanks.

dirn
  • 19,454
  • 5
  • 69
  • 74
PHPLover
  • 1
  • 51
  • 158
  • 311
  • 1
    Git is a _project_-based version control system, not a file based one. When you create a branch in Git, it has _all_ files in the repository, you can't pick and choose. Please review the tutorial and come back here afterwards. – Tim Biegeleisen Jan 12 '16 at 03:46
  • @TimBiegeleisen:Thanks for your suggestion. Are you saying it is impossible to add few files to a new git branch? If we create a new git branch all the project files must be included as of master branch? Am I getting you right? – PHPLover Jan 12 '16 at 03:48
  • Yes, you have it right. You can add new files of course, but then they will become a part of the repository. – Tim Biegeleisen Jan 12 '16 at 03:49
  • @TimBiegeleisen:Suppose I created a new git branch of my project. As you are saying it will be a replica of master branch. If I add new files to this branch or make few changes to files present in this branch; how will they get merged into the master branch? Is the process manual or automatic? – PHPLover Jan 12 '16 at 03:57
  • At the moment you branch off `master`, the new branch will be identical to the `master` branch. You can either merge or rebase the changes back into `master` when the time comes. You might want to try doing a bit of research on your own. – Tim Biegeleisen Jan 12 '16 at 04:02
  • @TimBiegeleisen: Than ks for the help and guidance you provided to me till now. Just last one question from me. What's the difference between merge and rebase? – PHPLover Jan 12 '16 at 04:12
  • Sure. If you were to merge your branch back to `master`, there would be one new single commit containing all the changes from that other branch. If you use a rebase workflow, the other branch would fast-forward `master` with all of its commits. Git is really powerful, and I hope you can pick it up. – Tim Biegeleisen Jan 12 '16 at 04:24
  • Possible duplicate of [How to detach subdirectory in Git but keep all branches](http://stackoverflow.com/questions/4319110/how-to-detach-subdirectory-in-git-but-keep-all-branches) – wogsland Jan 12 '16 at 04:28

1 Answers1

0

The basic building block of GIT version control is project. You can't branch off only some files from the master as it doesn't make any sense in an environment where projects are the single version controlled entities.

You can add or remove files from a branch and later commit to the master with the changes.

Some people refer to the branching model in Git as its “killer feature” , and it certainly sets Git apart in the VCS community. Why is it so special? The way Git branches is incredibly lightweight, making branching operations nearly instantaneous and switching back and forth between branches generally just as fast. Unlike many other VCSs, Git encourages a workflow that branches and merges often, even multiple times in a day. Understanding and mastering this feature gives you a powerful and unique tool and can literally change the way that you develop.

Charlie
  • 22,886
  • 11
  • 59
  • 90
  • Thanks for the informative answer you provided. I have one more question in my mind can you please provide proper explanation to it? The question is : I've a git repository set on some Git server. Using GIT client credentials I log in to Git client and download the project files present in the said Git repository. What this operation is called? When I do some changes/add new files I commit and push them to the Git repository. What this operation is called? What's the difference between code check-out and code check in? Thanks once again. Waiting keenly for your answer. – PHPLover Jan 12 '16 at 06:08
  • But what's the difference between code check-out and code check-in? – PHPLover Jan 12 '16 at 08:13
  • Check in - commit your chanages. Check out - update your working copy – Charlie Jan 12 '16 at 08:16
  • So if I download a zip of code from git repository to my local machine it will be called check-out and when I save and commit the changes I made to files it will be called check-in. Am I getting you right? – PHPLover Jan 12 '16 at 08:18
  • Downloading zip is not check out. You call it check out when you get the SVN to update your working copy with whatever the changes. Checking in - yes you get it right. – Charlie Jan 12 '16 at 08:20
  • This happens all the time. Check out ghp-import. The whole idea of creating a branch with just the stuff necessary to be a github page site is the purpose. – MichaelD Aug 23 '22 at 01:19