AutoQA AutoQA - 1 year ago 83
Git Question

Can a new file be created in Git with an existing file already on local machine

I can creat a new file in Git with the echo command:

echo > newFile.txt

After the file is created, i just usually navigate to the file directory from file explorer, update it with my codes and save it. It works okay.

The questiion is: If i already have a file containig all my codes in a workspace on my local machine, is there a way to tell Git to create a new file using that existing file instead of manually going to edit the new Git file? I think maybe it's possible to specify the existinng file path so that Git can go to fetch it?

Answer Source

Run git init from the directory where the files live. This creates a repository for your code.

You can then git add and git commit your files.

Following that, add an origin pointing to BitBucket so you can push your code.

git remote add origin git@bitbucket/path/bitbucket/gives/you/for/your/repo

git push -u origin master will create the master branch on the remote for the first time.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download