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?
The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch . Once created you can then use git checkout new_branch to switch to that branch.
Whenever we need to push the changes to a remote repository, we use git push along with the remote repository “origin” and “master” branches. The term used is “git push origin master“. To pull the changes from the remote repository to local, we use git pull along with remote repository “origin” and “master” branch.
Every time you commit, the master branch pointer moves forward automatically. The “master” branch in Git is not a special branch. It is exactly like any other branch. The only reason nearly every repository has one is that the git init command creates it by default and most people don't bother to change it.
Push a new Git branch to a remote repo Clone the remote Git repo locally. Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch.
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"
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With