Backstory: Recently, I’ve started a new job where I am going to learn a lot of new things, and therefore I want to keep track of, at least, some of them.
My normal Git workflow was (and still is when I am working on my solo projects) really basic, without any conflicts.
git clone name_of_the_repo.git
or creating a new one with git init
git pull origin master
before doing any changes just to be sure that everything is up to dategit checkout -b name_of_the_branch
git status
, just to see exactly all the files that were changedgit add .
, adding all the changes (including removing an existing file or creating a new one)git commit -m'Some explanatory message about the changes
git push origin name_of_the_branch
And that was basically everything. I would then merge the branch to master from GitHub and delete it afterwards.
The new workflow is not very different but there are some small details that I have to take into account. These are:
git add -p
(p stands from patch
). This will open an interractive window and you’ll have to go through each change and decide if you want to keep it or not (there are some other options like manual editing)git commit --amend --no-edit
git rebase -i origin/master
(i stands for interractive). This will open an interractive window, where I see all my commits and I’ll have to chose what to do with them. The default option is pick
, which basically means to leave everything as it is. Another one is squash
, which is used if I don’t want to have a long log history so it’s squashing the commitsgit rebase --continue
, which will lead to a selecting screen between the changes (the ones that I made and the ones that other people made), where I will have to select which one to keep (don’t forget to stage the changes here!). I run this command multiple times until everything is all rightgit push
(sometimes, it might need to be git push --force
if, for example, I squashed some commits)Other things to take into account is that the interractive mode is usually opened in VIM, which can be quite scary (it took me a while to figure out how to exit, lol), so here is a cheatsheet.
Ana Filote Self-taught front-end developer. Trying to learn new things.