recently we moved from TFS to GIT so I am still learning how to use this amazing tool.
At the moment I am working in a very simple structure like the following one:
main -------------------------------------- 01 ----------
\ /
dev ----------------------- 01 ---------- 02 ----------
\ / /
feat/login ------ 01 --- 02 --- 03 --- 04 --- 05 ---
- Developers work on
feature/something
and every tot hours they check-in and trigger a build with tests - When the feature is stable they merge back into
dev
which will contains 1 or more checkins fromfeature/something
- When the whole feature is ready, they merge the feature from
dev
intomain
The questions are the following:
- If I start to work from
feat/login
, if I dogit checkout dev
I don't get the latest code fromdev
but also my latest local file changed infeat/login
. How can I checkoutdev
without carry over the local changes not commited from my previous branch? - Assuming a developer made a mistake, how can I
rollback
to a previous check-in01
indev
and push it so that the latest check-in02
is not the last one anymore?
stash
your changes before checking out a different branch, orcommit
them.git reset
after switching. Bear in mind that when you later switch back, they won't magically reappear, that's why you have to commit or stash before switching.git reset
andstash
, I didn't know :-)git revert SHA-of-commit
to create another commit that reverts the effect of the one you want to undo.