Git - update current branch from master without committing current branch changes

I have looked at numerous questions on this same topic and they all have different answers and it is confusing.

Some say make your changes first, but I don't want to.

I also use Git Hub and don't understand how it works with website commands like making a pull request, comparing between forks, trying to change base, etc.

I thought I just dragged my current branch to the right square and dragged the main repo server branch to the left square and then clicked the Merge Branches button, but then a sync button appears in the upper right corner that should be clicked after that. i think and then you need to make a pull request on the website .... etc. etc.

Sheesh, in CVS, I just clicked update and it knocked all the changes in my head down to my current one and it was.

There are three options that I am guessing. By using the Git hub, using the website and / or using the command line. How can this be simplified?

+3


source to share


4 answers


It depends on what state your local repository is in relative to the upstream.

  • If there are conflicts , then you better compress your work before pulling in your branch. You can do it like this:

    git add . && git stash save
    git pull
    git stash pop
    
          

    If you don't want to deal with merging, you can re-create your branch instead, which doesn't require you to save your work (but give you some guidance on conflicts):

    git pull --rebase
    
          

    You will have to deal with conflicts using your merge tool of choice.

  • If there are no conflicts , you can simply pull in the branch.

    git pull
    
          



Github's role in all of this is to simply provide the remote repository that you pull / push into. There is no need to worry about this unless you have a remote setup; then I will give you their excellent documentation on setting up a remote repository.

+4


source


Your situation:

  • You are on a branch that may or may not be accessible upstream, which forked from an old master commit
  • You have no unspecified changes
  • You have uncommitted changes.

"Some people say make your changes first, but I don't want to."

There is no real reason; this is still your private working branch until you push

check back.

So:



If you haven't clicked yet:

  • git commit -m WorkInProgress

    (or git stash

    )
  • git rebase master

  • Resolve any conflicts
  • git stash pop

    if you hid

If you've already clicked:

  • Make sure your current branch matches product quality
  • git stash

  • git pull

    (won't conflict, but will create a merge commit)
  • git stash pop

+1


source


You can save your changes to the current branch with git stash. For more information see this: https://git-scm.com/book/en/v1/Git-Tools-Stashing

0


source


You can make patches that most IDEs and some tools provide, or if you are using Intellij IDEA there is a similar erase construct that is deferred, these changes are not saved in git, but rather in the IDEA project files.

But in the end, for your current situation git stash

, this is the way.

In the longer term, it's probably best to just read a little about git, as one of the differences between it and CVS is that you have to think in two phases. You are not interacting directly with your remote github or whatever. Your local repo is like your former Save button and remotely syncing the repo to your local. And even in CVS, most systems complained if you forgot to save ...

0


source







All Articles