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?
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.
Git is not about backing up files. It's about maintaining versioning of files/source. First thing is you need to have git repository. Seems like you already have source in a folder. Refer : https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ to see how you can add it to GitHub (or any other Git repository you prefer). And now when you have the new file inside this folder do a git status
. It should show if the file exists and if it is being tracked. Please follow : http://media.pragprog.com/titles/tsgit/chap-005-extract.html for more information. Then you can proceed to add
the file, commit
and push
.