repository interview questions
Top repository frequently asked interview questions
I have setup a local git on my machine. When I initialized git, I added pre-compiled libs and binaries. However, now during my development I don't want to check in those files intermittently. I dont want to remove these files from repo. Is there any way to not keep a track of these files till I complete my development. (I think I can not use .gitignore as it works only for those files which are not in git. I want to temporarily disable tracking of files.)
Source: (StackOverflow)
I wanted to rename one of my repositories on GitHub, but I got scared when a big red warning said:
- We will not set up any redirects from the old location
- You will need to update your local repositories to point to the new location
- Renaming may take a few minutes to complete
Does anyone have step-by-step instructions on how to accomplish #1 and #2 manually? Or what do I have to do locally?
Source: (StackOverflow)
My initial commit contained some log files. I've added *log
to my .gitignore
, and now I want to remove the log files from my repository.
git rm mylogfile.log
will remove a file from the repository, but will also remove it from the local file system.
How can I remove this file from the repo without deleting my local copy of the file?
Source: (StackOverflow)
I want to add the oracle jdbc driver to my project as dependency (runtime scope) - ojdbc14.
In MVNrepository site the dependency to put in the POM is:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
</dependency>
of course this does't work as it is not in the central repository used by maven.
2 questions:
How do I find a repository (if any) that contains this artifact?
How do I add it so that Maven will use it?
Source: (StackOverflow)
I want to have my local and remote repositories always in sync in terms of branches.
After a Pull Request review on GitHub, I merge and remove my branch there (remote).
How could I fetch this information in my local repository and get Git to remove my local version of the branch as well?
Source: (StackOverflow)
I am working with Git repositories in the following way:
- I have the master repository and several remotes on the different production machines.
- I am pushing the production code to the remotes and restart the services for the changes to take effect.
I am about to switch from Git to Mercurial and I would like to know ahead how I can achieve something like that.
Source: (StackOverflow)
Npm sounds like a great platform to use within an organization, curious if a private repo is possible, like with Nexus/Maven. Nothing comes up on Google :(
Source: (StackOverflow)
Consider the following scenario: I have developed small experimental project A in its own git repo. It has now matured, and I'd like A to be part of larger project B, which has its own big repository. I'd now like to add A as a subdirectory of B.
How do I merge A into B, without losing history on any side?
Source: (StackOverflow)
After successfully converting an SVN repository to Git, I now have a very large Git repository that I want to break down into multiple smaller repositories and maintain history.
So, can someone help with breaking up a repo that might look like this:
MyHugeRepo/
.git/
DIR_A/
DIR_B/
DIR_1/
DIR_2/
Into two repositories that look like this:
MyABRepo/
.git
DIR_A/
DIR_B/
My12Repo/
.git
DIR_1/
DIR_2/
I've tried following directions in this previous question but it doesn't really fit when trying to put multiple directories into a separate repo (http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository).
Source: (StackOverflow)
I've been reading about the bare and non-bare / default repositores in Git. I haven't been able to understand quite well (theoretically) about the differences between them, and why I should "push" to a bare repository. Here's the deal:
Currently, I'm the only one working on a project on 3 different computers, but there will be more people involved in it later, so I'm using Git for the version control. I clone the bare repo on all computers, and when I finish my modifications on one of them, I commit and push the changes to the bare repo. From what I've read, the bare repository does NOT have a "working tree", so if I clone the bare repo, I won't have a "working tree".
I'm guessing that the working tree stores the commit information, branches, etc. from the project. That wouldn't appear in the bare repo. So it seems better for me to "push" the commits to the repo with the working tree.
Then, why should I use the bare repository and why not? What's the practical difference? That would not be beneficial to more people working on a project, I suppose.
What are your methods for this kind of work? Suggestions?
Source: (StackOverflow)
We are working with a code repository which is deployed both to windows and linux, sometimes on different directories.
How should one of the modules inside the project refer to one of the non-python resources in the project (CSV file, etc.)?
If we do something like
thefile=open('test.csv')
or
thefile=open('../somedirectory/test.csv')
It will work only when the script is run from one specific directory, or a subset of the directories.
What I would like to do is something like:
path=getBasePathOfProject()+'/somedirectory/test.csv'
thefile=open(path)
Is this the right way? Is it possible?
Thanks
Source: (StackOverflow)
I'm working on a fairly big Maven project. We have probably around 70 or so individual artifacts, which are roughly split into two libraries of shared code and maybe ten applications which use them. All of these items live in the namespace com.mycompany.*
.
Most of the time we're running against snapshot builds. So to do a full build of an application, I might first build the library projects so that they are installed to my local repository (as, say, mycompany-libname-2.4-SNAPSHOT.jar
).
The problem is that when I then go build the applications. For some reason, Maven wants to check the main two public repositories (maven-net-repo and java-net-repo) for updates for all of the mycompany-*-SNAPSHOT.jar
artifacts. Of course, they aren't found there, and everything eventually resolves back to the versions I just built to my local repository, but I'd like Maven to stop doing this because (a) it makes me feel like a bad net.citizen for constantly checking these repositories for things that will never be there, and (b) it adds some unnecessary and annoying network latency into my build process.
I've taken to running maven in offline mode most of the time to work around this, but that's not ideal since occasionally a dependency on a public library will be updated. So what I'm looking for is a solution which will cause Maven not to check for updates from given repositories for artifacts which meet certain criteria - in this case, I'd be happy if Maven would ignore either SNAPSHOT versions or artifacts which were in the com.mycompany
namespace.
Source: (StackOverflow)
First, I know about this: http://stackoverflow.com/questions/51217/how-would-you-organize-a-subversion-repository-for-in-house-software-projects
Next, the actual question:
My team is restructuring our repository and I'm looking for hints on how to organize it. (SVN in this case).
Here's what we came up with. We have one repository, multiple projects and multiple svn:externals cross-references
\commonTools /*tools used in all projects. Referenced in each project with svn:externals*/
\NUnit.v2.4.8
\NCover.v.1.5.8
\<other similar tools>
\commonFiles /*settings strong name keys etc.*/
\ReSharper.settings
\VisualStudio.settings
\thrash /*each member of the team has thrash for samples, experiments etc*/
\user1
\user2
\projects
\Solution1 /*Single actual project (Visual Studio Solution)*/
\trunk
\src
\Project1 /*Each sub-project resulting in single .dll or .exe*/
\Project2
\lib
\tools
\tests
\Solution1.sln
\tags
\branches
\Solution2
\trunk
\src
\Project3 /*Each sub-project resulting in single .dll or .exe*/
\Project1 /*Project1 from Solution1 references with svn:externals*/
\lib
\tools
\tests
\Solution2.sln
\tags
\branches
To clear the vocabulary: Solution means single product, Project is a Visual Studio Project (that results in a single .dll or single .exe)
That's how we plan to lay out the repository. The main issue is, that we have multiple Solutions, but we want to share Projects among Solutions.
We thought that there is no point really in moving those shared Projects to their own Solutions, and instead we decided to use svn:externals to share Projects among Solutions. We also want to keep common set of tools and 3rd party libraries in one place in the repository, and them reference them in each Solution with svn:externals.
What do you think about this layout? Especially about the use of svn:externals. It's not an ideal solution, but considering all pros and cons, it's the best we could think of. How would YOU do it?
Source: (StackOverflow)
Preface: I'm attemping to use the repository pattern in a MVC architecture with relational databases.
I've recently started learning TDD in PHP, and I'm realizing that my database is coupled much too closely with the rest of my application. I've read about repositories, and using an IoC container to "inject" it into my controllers. Very cool stuff. But now have some practical questions about repository design. Consider the follow example.
<?php
class DbUserRepository implements UserRepositoryInterface
{
protected $db;
public function __construct($db)
{
$this->db = $db;
}
public function findAll()
{
}
public function findById($id)
{
}
public function findByName($name)
{
}
public function create($user)
{
}
public function remove($user)
{
}
public function update($user)
{
}
}
Issue #1: Too many fields
All of these find methods use a select all fields (SELECT *
) approach. However, in my apps I'm always trying to limit the number of fields I get, as this often adds overhead and slows things down. For those using this pattern, how do you deal with this?
Issue #2: Too many methods
While this class looks nice right now, I know that in a real world app I need a lot more methods. For example:
- findAllByNameAndStatus
- findAllInCountry
- findAllWithEmailAddressSet
- findAllByAgeAndGender
- findAllByAgeAndGenderOrderByAge
- Etc.
As you can see, there could be very, very long list of possible methods. And then if you add in the field selection issue above, the problem worsens. In the past I'd normally just put all this logic right in my controller:
<?php
class MyController
{
public function users()
{
$users = User::select('name, email, status')->byCountry('Canada')->orderBy('name')->rows()
return View::make('users', array('users' => $users))
}
}
With my repository approach, I don't want to end up with this:
<?php
class MyController
{
public function users()
{
$users = $this->repo->get_first_name_last_name_email_username_status_by_country_order_by_name('Canada');
return View::make('users', array('users' => $users))
}
}
Issue #3: Impossible to match an interface
I see the benefit in using interfaces for repositories, so I can swap out my implementation (for testing purposes or other). My understanding of interfaces is that they define a contract that an implementation must follow. This is great until you start adding additional methods to your repositories like findAllInCountry()
. Now I need to update my interface to also have this method, otherwise other implementations may not have it, and that could break my application. By this feels insane...a case of the tail wagging the dog.
Specification Pattern?
This leads me to believe that repository should only have a fixed number of methods (like save()
, remove()
, find()
, findAll()
, etc). But then how do I run specific lookups? I've heard of the Specification Pattern, but it seems to me that this only reduces an entire set of records (via IsSatisfiedBy()
), which clearly has major performance issues if you're pulling from a database.
Help?
Clearly I need to rethink things a little when working with repositories. Can anyone enlighten on how this is best handled?
Source: (StackOverflow)
I'm converting everything over to Git for my own personal use and I found some old versions of a file already in the repository. How do I commit it to the history in the correct order according the the file's "date modified" so I have an accurate history of the file?
I was told something like this would work:
git filter-branch --env-filter="GIT_AUTHOR_DATE=... --index-filter "git commit path/to/file --date " --tag-name-filter cat -- --all
Source: (StackOverflow)