Reputation: 1046
I followed this tutorial but I'm having trouble creating a new branch in a new repository. This is the error I'm getting:
What am I doing wrong?
Upvotes: 5
Views: 46327
Reputation: 481
If your project directory, where you do the git init, already has some files in it, then you have to git add .
and git commit
those changes in the master branch before git will let you create a new branch. That was the issue in my case. This might as well be the stanadard process for everytime you do a git init even with an empty directory, but in my case, I was initialising an already full directory.
Upvotes: 0
Reputation:
first you have to commit changes use git commit -a then use git branch again
Upvotes: 0
Reputation: 2063
Do these
git config --global user.name "YOUR NAME"
.
git config --global user.email "YOUR EMAIL ADDRESS"
and then create a branch
Upvotes: 1
Reputation: 32488
To create a git repository locally, you have to be inside the project directory, then run git init
command.
To add a file to git, you have to create a file, with some text editor for example. Then you have to add that file to git, then commit it locally.
git add .
git commit -m "A short description what you did to the file"
UPDATED based on the question update :
To create a git repository for a project
git init
to initialize a git repo for that projectgit branch <new branch name>
To add new files to the created repository
git add .
git commit -m "a Short description about the action you performed"
Upvotes: 9
Reputation: 201
git init
.git add .
git commit -m "your message"
This might also help: http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository
Code recap:
git init
git add .
git commit -m "your message"
Upvotes: 5
Reputation: 292
You just have to use the command line :
git add #filename
git commit #filename
Upvotes: 2