Search code examples
gitgit-branchgit-push

Can we push our code GIT feature branch?


We are following GIT branching strategy mentioned here

We are creating feature branches from develop, and working on new features.

We wanted to store the code in feature branch, that is currently under development to save our day-to-day work.

GIT branching strategy does not mentioning anything specific about pushing the code to feature branch.

I need expert advice here, can we do

git push origin feature/feature_branch_name

at the end of each day, to save our WIP (sometimes yet to test) code?

or

Please let me know, is there any other best practice available to store the feature code development.


Solution

  • This is exactly the concept using branches - develop new code and fix bugs without working on the current branch.

    This is the right way to work and you understood it correctly.


    git branch

    A branch represents an independent line of development.

    Branches serve as an abstraction for the edit/stage/commit process discussed in Git Basics, the first module of this series. You can think of them as a way to request a brand new working directory, staging area, and project history.

    New commits are recorded in the history for the current branch, which results in a fork in the history of the project.


    In Git, branches are a part of your everyday development process.

    When you want to add a new feature or fix a bug —no matter how big or how small—you spawn a new branch to encapsulate your changes.

    This makes sure that unstable code is never committed to the main code base, and it gives you the chance to clean up your feature’s history before merging it into the main branch.