Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push temporary changes?

Tags:

git

Git noob here. Here's my conundrum:

  1. I want to push code to have a log of my effort & history of changes
  2. The new code is not finished yet, and will break

Is there a way to "lightly" push changes, just to show what I've been working on, but won't update others' local files if they pull the Branch?

I usually push code like this:

git add .
git commit -m "this code doesn't work yet, and shouldn't be pulled"
git pull origin myBranch
git status
git pull origin myBranch

What should I use to accomplish this? A new Branch? A Fork? I'm not too sure about the terminology, if I knew I could easily goog it.

like image 234
Travis Heeter Avatar asked Apr 26 '17 12:04

Travis Heeter


2 Answers

No. Just push to a different branch. This is an issue of branch policies, which your team needs to define.

like image 192
Jonathon Reinhart Avatar answered Nov 15 '22 04:11

Jonathon Reinhart


If you push your changes on the remote repo, your teammates will see theses changes, so a good practice is to create a feature branch (see the git-flow recommendation) which will be merged into the current branch latter.

In this feature branch you can push useless commits, it doesn't matter if you push bad commits messages BUT once you are ready to merge the feature branch into the branch used by your mates you can run this command before git rebase -i, in order to rewrite the history to keep only useful commits messages.

like image 36
Olivier Boissé Avatar answered Nov 15 '22 02:11

Olivier Boissé