Disclaimer: Once agian this page is probably just a mishmash of my random thoughts, and will most likely get you into trouble.
Need to read the git book again really! Keep testing.
Un-tracked and un-commited CHANGES (new file, deleted file, whatever) will always appear in your working dir (they are in the index, the index isn't anything to do with branches.) The changes you have made will be commited to the current branch when you commit
Initialize a new git repo
init
Add a new or changed file to the index, staging it for the next commit. You don't have to add files, you can leave them out until you're ready to have them tracked.
add somefile (or wildcard, . or what not)
Add everything and commit in this branch
commit -a
Create a new branch
branch mybranchname
Switch to a different branch (! You can't switch unless changes are commited or stashed in the current branch)
checkout mybranchname
Stash your changes on current branch to avoid having to commit them (or having them merged.) Note that stashing will remove (until unstashed) all your changes since the last commit of the branch:
stash
Un-stash:
stash apply
List stashes:
stash list
See what branch we're on
branch
Merge changes from mybranchname to current branch (! if they're commited from mybranchname they'll be commited in current branch)
merge mybranchname
john@workvm:~/git-test$ git init Initialized empty Git repository in /home/john/git-test/.git/
john@workvm:~/git-test$ ls afile a.out hello.c
john@workvm:~/git-test$ git add .
john@workvm:~/git-test$ git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: a.out # new file: afile # new file: hello.c #
john@workvm:~/git-test$ git commit -m "Git test project" Created initial commit afa7dff: Git test project 3 files changed, 12 insertions(+), 0 deletions(-) create mode 100755 a.out create mode 100644 afile create mode 100644 hello.c
john@workvm:~/git-test$ git status # On branch master nothing to commit (working directory clean)
john@workvm:~/git-test$ git branch development
john@workvm:~/git-test$ git status # On branch master nothing to commit (working directory clean)
john@workvm:~/git-test$ git branch development * master
john@workvm:~/git-test$ git checkout development Switched to branch "development"