Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent to git stash in perforce?

Tags:

git

perforce

I've dug through the interwebs all I can, and I can't for the lack of me find any way of easily stashing or branching locally with perforce. I know of the git wrapper for perforce, but it really doesn't seem too well developed or reliable from everything I've read about it.

like image 504
bergyman Avatar asked Jan 20 '10 19:01

bergyman


People also ask

What is opposite of git stash?

You can just run: git stash pop. and it will unstash your changes.

What is the difference between stash and shelve in git?

Stashing changes is very similar to shelving. The only difference is in the way patches are generated and applied. Stashes are generated by Git, and can be applied from within IntelliJ IDEA, or outside it. Patches with shelved changes are generated by IntelliJ IDEA and are also applied through the IDE.

What is the difference between stash and git?

The git commit and git stash commands are similar in that both take a snapshot of modified files in the git working tree and store that snapshot for future reference. The key differences between the two are as follows: A commit is part of the public git history; a stash is stored locally.

Is git stash a stack or queue?

Details: Every documentation, article and book (except Git Internals) says that the git stash is a stack.


2 Answers

Perforce 2009.2 has shelve and unshelve, that let you put modifications on the server, without checking them in. http://blog.perforce.com/blog/?p=1872

I think that provides the sort of functionality you want?

If you aren't yet using 2009.2, there are also P4_Shelve and p4tar as possible alternatives.

like image 145
Douglas Leeder Avatar answered Sep 20 '22 08:09

Douglas Leeder


Regarding branching, I doubt you can "branch" locally in Perforce, nor could you natively stash.

  • Git is based on a graph of commits (a DAG - Directed Acyclic Graph actually), which will display only the content of a commit (trees and blobs)
  • Perforce is a linear VCS, based on composition of selection rules (it will compose what to display based on local selection rules)

Regarding branching:

  • A branch in Git is just a light-weight and local alias to a head[*] / tip commit.
  • A branch in Perforce is:
    • a codeline (most likely meaning when used as a noun)
    • a branch view specification (as in the entity created by "p4 branch" command - also a noun) - these are talked about below
    • when used as a verb ("to branch") it means to use the "p4 integrate" command to create a new codeline (or branch!) of one or more files

As mentioned in this introduction to perforce branching, Perforce, being heavily linked to its central depo, need to create the relevant metadata for each files to create a branch.
Git would only write some bits to register the creation of a new branch!

[*] git branches are stored in the .git/refs/heads/ subdirectory

like image 21
3 revs, 2 users 90% Avatar answered Sep 21 '22 08:09

3 revs, 2 users 90%