The team is switching from Perforce to Gitlab. As a part of the process, we noticed that git supposedly has a disadvantage of shelving files which Perforce does effectively.
Say I am working on a feature and I want to share a few files with a teammate. In Perforce, I'd just shelve the files and share the CL number, which my teammate can unshelve and view.
In git, I need to create a branch, add the files, commit them and push to origin. The teammate(s) then need to checkout the branch, pull changes and view. That's a lot of steps.
How do I automate this to a single command? Essentially I'm looking to create a command called git shelve which can
- Create a new branch, add the files from staging area to the branch, commit the files, push them and return the name of the branch to the user after the process is finished(or throw error if any step fails).
- a. Optionally, give the user to choice the name of the branch
- Another user runs the command
git unshelve <branch name>. This checks out the branch, pulls the latest changes and displays the file names which were changed.
- a. Optionally, give the user an option to delete the branch if the unshelve operation is successful
So essentially I want to achieve the effect of git stash and git stash pop, but want the latter to be run on my teammate's machine.
Please help me achieve this automation. Can this be done by writing bash scripts, which are installed on respective machines?
Git likes to name things.[1] You can’t push around commits (to my knowledge) without giving things names first. But you can automate the name-giving and in turn make any commit shareable without having to worry about names.
refs/tags/throwaway/git-shelve:git-unshelve:A boring disclaimer
This is a very non-standard workflow.
Notes
From:
My lack of experience with other VCS means that I cannot speak about my own experiences here.