top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Git: can I make two local repos be identical, always, except for current branch?

+5 votes
372 views

basically, I've got clones of some expensive-to-build projects (node.js), and I have changes that I want to rebase/cherry-pick onto dev and stable branches.

I know I can push to a remote, then pull into my other, and keep the two on different branches so the builds don't get out of date. But, I think I'd like it if they all just shared the same objects, branches, etc...

Could I symlink together my .git{branches,config,hoks,logs,objects,packed-refs,refs} directories? Is this just going to kill me later?

posted Oct 25, 2013 by Kumar Mitrasen

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+2 votes

I would like to know what are the best practices when creating a new branch. For example. If I get a request to do update website title from XYZ to ABC; then should I create a branch named; "Update Title"? Or I should prefix this as suggested here (http://stackoverflow.com/questions/273695/git-branch-naming-best-practices). Are there any official prefixes?

Also I am concerned about the following; Let us say I create the branch named "Update Title". Finish the change. Merge back with Master. I then get another request to change title from ABC to DEF. Can I create another branch "Update Title". Will not this be confusing?

+2 votes

How do I switch to a hash on a branch without creating moving to a new branch? Say I'm currently at the HEAD of master, and its hash is aaa. I want to stay on master, only switch to a previous hash... (say eee...)

I know I can use the HEAD~ or whatever, but I'd like to find out how to do it based only on a hash...

+1 vote

I have heard conflicting statements about the impact of branching in git. Let's say we have 100 feature branches that are all stored in a remote repo, would that affect performance (CPU/network) in a noticeable way ? How about 1000? 100,000 branches? In other words how does git scale with regards to number of branches?

+1 vote

At some point I added a large file into a git repository. It now exists on multiple branches, possibly with some changes to it. I'd like to remove it from git, but leave its current form (say the one on the master branch) on the file system.

I tried (on a dummy git archive)

git filter-branch --index-filter 'git rm --cached --ignore-unmatch bigfile' master branch1 branch2

That, however, does not leave a copy of bigfile on the file system.It isn't clear to me why not, though the description of the --tree-filteroption to filter-branch (I'm using the --index-filter option, but is is "similar") states:" (new files are auto-added, disappeared files are auto-removed ... )".
Is there a direct way to do what I want, with git? I've found similar requests;none of the responses point out that the above command actually deletes the file from the file system.

+1 vote

I just had the bare vs non-bare repo concept smack me in the face. Painful way to learn things, but I won't forget it any time soon. Since my remote repos are no longer work trees, how can I keep two bare repos in sync? This is primarily for DR purposes.

Here's more detail in case it'll help:
I have two rhel6 systems running git 1.7.1 that will be maintaining OS and web configuration files for a variety of teams, once I get the bugs in my understanding ironed out. One git server is in datacenter A (prod) where most of the updates will be occurring. Appropriate people will clone the bare repo, make their updates and push it back. The other git server is at our warm DR site. While rare, updates to this server should be possible.

I need to be able to fetch changes from the production git server and apply them to the DR one. When I tried it straight, I got the expected "fatal: This operation must be run in a work tree"

I suppose I could hack out a script to pull the configs down to a temp repo and push them back up to the DR one (and vice versa), but that seems like a kludge. As flexible and seemingly well thought out as git appears to be, I have to believe there's a better approach.

Could someone clue me in on what I'm missing or how a generic DR process is typically set up?

...