How to push temporary changes?
Git noob here. Here's my puzzle:
- I want to push code to have a log of my efforts and a history of changes.
- The new code is not finished yet and it will break
Is there a way to "lightly" push changes, just to show what I'm working on, but won't update others' local files if they pull 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 for this? New branch? Fork? I'm not too sure about the terminology if I knew I could get it up and running easily.
source to share
If you push your changes to the remote repo, your teammates will see those changes, so it is good practice to create a branch feature
(see git-flow recommendation ) that will be merged with the most recent branch.
In this feature branch, you can use useless commits, it doesn't matter if you push bad posts with a commit BUT , once you are ready to merge the feature branch into the branch your helpers use, you can run this command before git rebase -i to rewrite history to keep only useful commit messages.
source to share
You can push your work to any number of local .git
branches (for example, stored in a directory next to your working copy) as you wish, without dragging them into another repository (for example, a central server).
This way you have a record of your work without affecting others.
Once you know your work is ready for others, you can click.
source to share
There is git
no such thing as a "light" branch. It is not possible to create a remote branch that will be available for pulling to others, but will not modify the local working tree.
You need to push a branch somehow marked as yet unfinished. A popular technique is to append [WIP]
to branch names or commit messages that they Work in Progresss
:
https://docs.gitlab.com/ce/user/project/merge_requests/work_in_progress_merge_requests.html
https://gerrit-review.googlesource.com/Documentation/config-plugins.html#wip
Or from https://github.com/blog/1943-how-to-write-the-perfect-pull-request :
Be honest when you need feedback if a Pull Progress request is, shall we say. The "[WIP]" prefix in the name is a simple, general pattern to indicate this state.
source to share