Git: Committing vs Pushing vs Stashing – OR: “what to do if I just want to work locally”
- Apr 20, 2016
- 3 min read
Updated: Feb 2, 2020

Many people ask me for advice when they’re trying to modify some code locally without the changes finding their way into the remote repository or – gods forbid – the production. This makes me realize that there’s some gap in understanding what Git is and how it works.
When you perform a ‘git clone ‘, what you’re saying is “I’d like to make some contribution to the project at the remote repository” (or fork it, but that’s another use case that doesn’t really interest most of you so we’ll ignore it). Git copies the remote repository to your local machine, and marking your copy as a remote tracking branch of the repository you cloned from.
After your changes have reached some point when they form a meaningful, atomic change to the system, you commit them into your local repository using ‘git commit’. By that, you’re saying “Gee, this looks like a good idea, I’d like to contribute it back to the project. I don’t know when exactly I’ll physically send my copy back to the original repository but I definitely want it to get there.”.
Then, at some point, you send your changes to the remote repository using ‘git push’, thereby saying “I have reached a point in time where the original project needs / could use my work, so let’s send it there now”. In most cases, before you can do that you’ll have to update your local copy with the changes that occurred in the remote repository since your clone / since the last time you updated. You do that by using ‘git pull’ (or ‘git pull –rebase’, if you prefer, like me, using rebase rather than merge). After merging/rebasing your local repository against its remote counterpart, you can push your changes, making the product guys happy that your change is finally available for testing / deployment.
All that is jolly fun, but what if you want to make some temporary, local changes that you never want to merge with the remote repository. If you’re working on a new file, you can just add it to your local .gitignore file, making Git ignore this file for all eternity. But if you’re just modifying some pre-existing file, you’re out of luck – you’ll just have to edit the file and remember never to commit it. Which is fine, until you have to pull changes from the remote repository, whereupon Git explodes telling you that you have some uncommitted / untracked changes. At this point, you have to make your changes “temporarily go away” so that Git can successfully complete the pull. The proper way to do that is by using ‘git stash’. This will make all local, uncommitted changes go away temporarily, until you call ‘git stash apply’, which will then merge your local changes with the latest updates from the remote repository.
Sure, you could always commit your changes, pull from the remote repository, then revert your commit, but that’s kinda like beating a baby seal to death with a baseball bat. You just don’t do that, no matter how tempting this might sound to your deranged mind.
In summary:
Your local repository is a full copy of the remote repository. It’s not a working copy.
When you commit a file, you’re saying ‘This change should eventually reach production’.
When you push your local repository to its remote counterpart, you’re saying ‘The production could sure use my amazing new code right about now’.
If you don’t want your change to reach production, don’t commit it.
If you’re having trouble merging/rebasing because of untracked local changes, perform the following:
git stash
git pull / git pull –rebase
make sure that the operation completed successfully. You should read the stuff Git reports after performing a pull, often it will tell you of conflicts that make your rebase partial; in this case you should amend the conflicts and continue the rebase using ‘git rebase –continue’.
git stash apply

This post was written by Shai Yallin
You can follow him on Twitter
For more engineering updates and insights:
Visit us on GitHub
Subscribe to our YouTube channel



Буває, що назва бренду знайома, а його розміри — ні. У такій ситуації логічніше не шукати універсальне правило, а одразу звіритися з https://zastibka.com.ua/brendy/mamyn-dim/. Для Мамин дім це має сенс через те, що бренд охоплює білизну для годування, одяг для вагітних і дитячі речі, а різні категорії можуть вимагати різного підходу до вибору.
Ще один практичний момент — повторювати заміри час від часу. Пара сантиметрів різниці непомітна в побуті, але її вже достатньо, щоб сусідній розмір виявився комфортнішим. У випадку Мамин дім я б окремо тримав у голові таку практичну річ: дивитися на обхвати, зріст та вікові позначення окремо для кожної групи товарів. Це набагато надійніше, ніж автоматично повторювати розмір з речі іншого виробника.
Застібка тут корисна саме як довідник по…
Сам датчик зазвичай справний, а от гелева подушка під ним одноразова, і саме через її пошкодження після заміни скла склоочисники починають працювати хаотично. Розбір, Чи потрібно міняти датчик дощу під час заміни лобового скла, з поясненням обох випадків є за посиланням. Перевіряти роботу датчика варто одразу в сервісі, поливши скло водою: повертатися з претензією через тиждень значно складніше.
Starting August 12, a new rule will take effect in the EU: product packaging will change—both in appearance and in how it works. So you’ll soon notice the difference when you shop.
Часом знаходжу ці джерела випадково, іноді хтось скине в чат, іноді сам зберігаю “на потім”. Частину переглядаю рідко, частину — коли шукаю щось локальне чи нестандартне. Вони різні: новини, огляди, думки, регіональні стрічки. Я не беру все за правду — скоріше, для порівняння та пошуку контрасту між подачею. Можливо, хтось іще знайде серед них щось цікаве або принаймні нове. Головне — мати з чого обирати. Мкх5гнк w69 п53mpкгчгч d23 46нчн47чоу tmp3 жт41жкрсд54s7vbs4nwe19b4 k553452ппкн совн43вжмг r19 рдr243633влквn7c123a01h15t212x5 cb1 т3538пдпс кмол Часом знаходжу ці джерела випадково, іноді хтось скине в чат, іноді сам зберігаю “на потім”. Частину переглядаю рідко, частину — коли шукаю щось локальне чи нестандартне. Вони різні: новини, огляди, думки, регіональні стрічки. Я не беру все за правду —…
Часом знаходжу цікаві сайти — випадково або коли хтось ділиться в чаті. Частину зберігаю про запас, іноді повертаюсь до них при нагоді. Тут є різне — новини, блоги, локальні стрічки чи просто незвичні штуки. Деякі переглядаю рідко, деякі — коли хочеться вийти за межі звичних джерел. Поділюсь добіркою — може, хтось натрапить на щось нове: Мкх5гнкw69п53mpкгчгч d23 46нчнчоу жт41жкрсд54s7vbs4nwe19b4k553452ппкн совн43вжмг r19 r243633влквn7c123a01h15t212x5 cb1 т3538пдпс кмол Щодо загальної інформації — іноді буває корисно мати кілька додаткових ресурсів під рукою. Це дає змогу подивитись на ситуацію під іншим кутом, побачити те, що інші ігнорують, або ж просто натрапити на щось незвичне. Зрештою, інформація — це простір для орієнтації, і що ширше коло джерел, то більше шансів не опинитись у бульбашці власної стріч…