Git, Doubt when I commit

Asked

Viewed 98 times

7

I have a question when using git, and would like your help.

I have the following situation:

  • I’m developing a new feature in my application, but I haven’t completed it. Let’s assume I’m developing it on the home pc. Then I go to work, and I decide, at lunchtime, to continue the new appeal.

Follow my question... The application is on Github. I developed it on the home pc, and I ate inconpleto finish it at lunch time at work...

What is the solution for not committing incomplete things in git?

Thanks in advance!

  • 2

    Normally you use a branch process to prevent new things from falling into production immediately, only approving later after intensive review

  • 1

    You can help: https://answall.com/a/80586/64969

  • 1

    Here I talk about a not very traditional view of git: https://answall.com/a/242019/64969

1 answer

6


Create a branch/branch where you have this new/Feature feature. When it is ready merge with the master.

git checkout master
# criar novo ramo a partir do master
git checkout -b nova-ideia

And then at work:

git fetch origin # ou outro nome que deste ao repositório remoto
git checkout nova-ideia (sem o "-b" que é para criar novo)
  • 1

    The command git pull origin would also work?

  • 1

    @cat depends on what you want to do. git pull updates the branch you’re on, merge. If it’s to update what’s in the remote (in memory) git fetch brings the fresh information.

  • 1

    Thanks Sergio. I’m going to do some tests here. But I think that’s the way!

  • I have a question. git checkout -b new-idea, will create a new branch. I can upload the changes from this new branch to the server without the commit? My architecture looks like this: Home PC + Bitbucket + Work PC

  • @Samuelgomes must commit to go up to the server. But in the branch nova-ideia you can delete the commit and rewrite the history. I usually upload it to git and continue on another computer. Then when a piece is fixed I commit permanently. When the whole branch is ready I merge with the master.

  • @Sergio how do I delete the commit without deleting what was done? But I got it. Thanks!

  • 1

    @Samuelgomes git reset --soft HEAD^1 delete the last commit and leave the changes in place. Then if you need to update the new branch you can do git push -f origin but even: never do that on master! Make sure you’re in the right business :)

  • 2

    @Sergio you are myth. Thank you!

  • 2

    @Samuelgomes glad to help :)

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.