Re: Basic Git usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hogsolo <greg@xxxxxxxxxxxxx> writes:

> Hi, Im new to Git, formerly an SVN user.
>
> I have a master repo and have created a branch. I want to work in both at
> the same time. I want to change some files in the master, then switch to the
> branch ( git checkout branchname) , work on some files, then switch back to
> the master. 
>
> However git wont let me switch back to the master until I have added,
> committed and pushed my files in the branch. 
>
> Is this correct behavior for git? It would seem that I not be REQUIRED to
> check in anything I was working on before switching between branch and
> master, but that's the behavior I'm seeing via error messages.

Git wouldn't allow you to switch a branch ('git checkout <branch>') if
you have uncomitted changes that would conflict with the branch you
switch to.  For example if you have uncomitted changes to file 'foo',
and this file is different on the branch you switch to, then git rightly
refuses to switch branches.

You can tell git to try to merge changes with

  git checkout -m <branch>

or you can force git to discard your local changes with

  git checkout -f <branch>

or you can stash away your changes before switching branch.


In no case _pushing_ changes is a requirement.

-- 
Jakub Narebski
Poland
ShadeHawk on #git
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]