I just started using Git, and I come from Perforce. I am wondering if Git has a 'shelf' feature similar to Perforce.
For example: If I am currently working on a ticket in Perforce and I need to switch to another ticket, I would shelf my work in a changelist, and create another changelist for this new ticket. The work for my original ticket is shelved safely in my first changelist and is available for me to retrieve. I am wondering if I can perform a similar action in Git.
You can do this with git branches like:
$> git checkout -b ticket-1 // creates a new branch $> normal workflow $> git commit -m "Changes" file1.txt // commit changes
You can move to another ticket with:
$> git checkout master //cleans changes (stored safely with a branch) $> git pull origin master // pull any latest changes - more like p4 sync $> git checkout -b ticket-2 // new branch $> normal workflow $> git commit -m "New changes for ticket-2" file2.txt
git stash is another way. The one described above is useful in case you want to share your work via review or for a peer to checkout files etc...