Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git branches behaving strangely

Tags:

git

It seems like I have inadvertently modified my git config such that when I switch from branchA to master all changes are automatically merged to master. This happens without either my committing in branchA or my merging to master. In the past if I tried to switch branches after modifying a tracked file and without committing, I got "the uncommitted changes, can't switch branches" message, but now I'm unable to induce that behavior. Something has changed with my git config, but I have no idea what it might be. Does this sound familiar to anyone?

Any help is greatly appreciated.

Ubuntu 10.10
git 1.7.1
github.com

here's my git config -l:

giggle.main-window-maximized=false
giggle.main-window-geometry=993x731+318+160
giggle.history-view-vpane-position=223
giggle.main-window-view=HistoryView
giggle.file-view-vpane-position=153
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=**************************************
branch.master.remote=origin
branch.master.merge=refs/heads/master
submodule.config/shared_capistrano.url=******************capistrano.git
submodule.vendor/plugins/authentication_client.url=********************.git
branch.dev.remote=origin
branch.dev.merge=refs/heads/dev
branch.1.3.9.remote=origin
branch.1.3.9.merge=refs/heads/1.3.9
like image 989
user508546 Avatar asked Jun 13 '11 22:06

user508546


People also ask

Does git pull fetch all branches?

Git fetch commands and optionsFetch all of the branches from the repository. This also downloads all of the required commits and files from the other repository. Same as the above command, but only fetch the specified branch. The --dry-run option will perform a demo run of the command.

What is git branch command?

The git branch command lets you create, list, rename, and delete branches. It doesn't let you switch between branches or put a forked history back together again. For this reason, git branch is tightly integrated with the git checkout and git merge commands.


1 Answers

When you are switching branch and the files are only locally modified, Git will not give you the warning / message ( and will merge the changes into the other branch). For example, you have your repo on master, create a branch temp, have a local modification on the file. Now, when you switch to master you won't get the message. If on the other hand you makes changes in temp and commit them ( that is temp diverges from master ) and then you have local modifications, it will give you that message when you switch to master

like image 196
manojlds Avatar answered Sep 30 '22 14:09

manojlds