Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 755419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:07:40+00:00 2026-05-14T15:07:40+00:00

At work, development uses perforce to handle code sharing. I won’t say revision control,

  • 0

At work, development uses perforce to handle code sharing. I won’t say “revision control”, because we aren’t allowed to check in changes until they are ready for regression testing. In order to get my personal change sets under revision control, I’ve been given the go-ahead to build my own git and initialize the client view of the perforce depot as a git repo.

There are some difficulties in doing this, however.

  1. The client view lives in a subfolder of ~, (~/p4), and I want to put ~ under revision control as well, with its own separate history. I can’t figure out how to keep the history for ~ separate from ~/p4 without using a submodule. The problem with a submodule is that it looks like I have to go make a repository that will become the submodule and then git submodule add <repo> <path>. But there is nowhere to make the submodule’s repository except in ~. There seems to be no safe place to create the initial client view of the depot with git p4 clone.

    (I’m working off of the assumption that initing or cloning a repo into a subdirectory of a git repo is not supported. At least, I can find nothing authoritative on nested git repos.)

    edit: Is merely ignoring ~/p4 in the repo rooted at ~ enough to allow me to init a nested repo in ~/p4? My __git_ps1 function still thinks I’m in a git repository when I visit an ignored subdirectory of a git repo, so I’m inclined to think not.

  2. I need the “remote” repository created by git p4 sync to be a branch in ~/p4. We are required to keep all of our code in ~/p4 so that it doesn’t get backed up. Can I pull from a “remote” branch that is really a local branch?

  3. This one is just for convenience, but I thought I could learn something by asking it. For 99% of the project, I just want to start the with the p4 head revision as the inital commit object. For the other 1%, I would like to suck down the entire p4 history so that I can browse it in git. IOW, after I’m done initalizing it, the initial commit of remotes/p4/master branch will contain:

    revision 1 of //depot/prod/Foo/Bar/*
    revision X of other files in //depot/prod/*, where X is the head revision
    

    and the remotes/p4/master branch contains Y commits, where Y is the number of changelists that had a file in //depot/prod/Foo/Bar/*, with each commit in the history corresponding to one of those p4 changelists, and HEAD looking like p4’s head.

Edit: meagar’s answer didn’t quite work for me.

I have initalized ~ and checked in a few commits to it. I have ignored ~/p4 and ~/p4 is not in any commit object.=:

[~@ernie02] (master) $ git show HEAD:p4
fatal: Path 'p4' exists on disk, but not in 'HEAD'.

I then went to ~/p4/prod, a branch I want to check out. But this repo is broken:

[~/p4/prod@ernie02] (master) $ git log
(shows the log for the repo rooted at ~)
[~/p4/prod@ernie02] (master) $ git init
Initialized empty Git repository in ~/p4/prod/.git/
[~/p4/prod@ernie02] (master) $ git log
fatal: bad default revision 'HEAD'

Edit edit: Oops, I forgot to commit something to ~/p4/prod. I’m trying a git p4 sync //depot/prod to it now…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:07:41+00:00Added an answer on May 14, 2026 at 3:07 pm

    In answer to #1, if you really want to have your whole home directory in a git repository, but have ~/p4 in a seperate repository, just add “p4” to .git_ignore in your home directory, and make another repo in p4:

    $ cd ~
    $ git init
    $ echo "p4" > .git_ignore
    $ git add .git_ignore
    # add all files/directories except p4
    $ git commit
    $ cd p4
    $ git init
    $ git add .
    $ git commit
    

    I don’t quite follow #2, but yes, you can pull from a “remote” repo that is local to your file system. As far as “pulling” from local branches, that isn’t pulling; pulling involves a fetch and a merge. If you omit the fetch, it’s just a merge, so you’re really talking about merging from a local branch.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 459k
  • Answers 459k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Sorry, answered my own question, key was to switch to… May 15, 2026 at 11:36 pm
  • Editorial Team
    Editorial Team added an answer Well, welcome at SO then ;-) In XML, a namespace… May 15, 2026 at 11:36 pm
  • Editorial Team
    Editorial Team added an answer I stumbled on this the other day: http://aralbalkan.com/3331 This will… May 15, 2026 at 11:36 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.