All of lore.kernel.org
 help / color / mirror / Atom feed
* Basic Git usage
@ 2010-08-14  4:32 hogsolo
  2010-08-14 12:39 ` Jakub Narebski
  2010-08-14 19:41 ` Dmitry Potapov
  0 siblings, 2 replies; 3+ messages in thread
From: hogsolo @ 2010-08-14  4:32 UTC (permalink / raw)
  To: git


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.

thanks


-- 
View this message in context: http://git.661346.n2.nabble.com/Basic-Git-usage-tp5422412p5422412.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Basic Git usage
  2010-08-14  4:32 Basic Git usage hogsolo
@ 2010-08-14 12:39 ` Jakub Narebski
  2010-08-14 19:41 ` Dmitry Potapov
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Narebski @ 2010-08-14 12:39 UTC (permalink / raw)
  To: hogsolo; +Cc: git

hogsolo <greg@localdirt.com> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Basic Git usage
  2010-08-14  4:32 Basic Git usage hogsolo
  2010-08-14 12:39 ` Jakub Narebski
@ 2010-08-14 19:41 ` Dmitry Potapov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Potapov @ 2010-08-14 19:41 UTC (permalink / raw)
  To: hogsolo; +Cc: git

On Sat, Aug 14, 2010 at 8:32 AM, hogsolo <greg@localdirt.com> wrote:
>
> 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.

If you have modified files that are different between two branches then
Git won't allow to switch between them. You have two options:
- to commit your changes
- use "git stash"

In contrast to SVN and some other VCS, Git allows you to amend any commit
later. To amend the last commit on the current branch, 'git commit --amend'
can be used. If you want to modify arbitrary commits, (or squash, or delete
some commits) take a look at: "git rebase --interactive"

Warning: modifying commits that you published (i.e. made available to
other users) is in general a bad idea, because it makes difficult for
other users to work with you.


Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-14 19:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-14  4:32 Basic Git usage hogsolo
2010-08-14 12:39 ` Jakub Narebski
2010-08-14 19:41 ` Dmitry Potapov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.