Update: according to the link in my question below, ‘M’ seems to mean Merge’d when you see it during a branch change, but Modified with git status: “When we switch to the master branch, the working directory is considered “dirty” since the README file has not been added to the index and committed. As a result, git will attempt to merge the contents of README from the test branch into the README file in the master branch:”
Forgive my git ignorance, but why is it when I make changes in an upstream branch, and then checkout my master branch (without commit’ing), the modified file follows the current branch as a Merge? I thought git only merged when I told it to merge. I don’t always want my edits to propogate to another branch so is there a way to tell git to ask before merging?
iow: How can I tell git to keep me from screwing up another branch if I acccidentally switch to it with un-commit’d edits in my current branch?
[on branch:foo]
$ echo test >> main.c
[on branch:foo]
$ cat main.c
#include <stdio.h>
int main void (int argc, char **argv)
{
printf ("Hello world!\n");
return (0);
}
test
[on branch:foo]
$ git checkout master
M main.c
Switched to branch 'master'
[on branch:master]
$ cat main.c
#include <stdio.h>
int main void (int argc, char **argv)
{
printf ("Hello world!\n");
return (0);
}
test
[on branch:master]
$
It depends on what you want to do with the changes.
If you wanna throw them away use
git checkout -f masterIf you wanna save them for later,
git stashthe changes to clean the working tree andgit popto apply the changes again whenever and wherever you want.If you want the changes to stay in the branch, just
git committhe changes beforegit checkout master.