Reputation: 1158
I wanted to use git for the Sunshine app which we are doing as a part of Udacity's UD853 "Developing Android Apps". I know Android Studio has a built-in GUI based Git plugin, but I wanted to do it with the CLI of Git Bash.
So I first cd to the project folder by $ cd AndroidStudioProjects/Udacity01Sunshine
Then to make it a git repo, I ran $ git init
Then to add all the files to the staging area, I ran $ git add .
Then for committing them, I typed $ git commit
, and gave "Initial commit" as the commit message.
After that, for adding the remote at https://github.com/adityanaik/Udacity01Sunshine , I typed $ git remote add origin https://github.com/adityanaik/Udacity01Sunshine.git
Then for pushing the local git repo to the remote, I ran $ git push origin master
Then created README.md on GitHub, and pulled the commit to the local repo with $ git pull origin master
I think I did it right, but still got some doubts over $ git add .
Should it have been $ git add -A
considering it was for the first commit?
Please help me with this, I'm new to git. Learned it over the last 3 days from Udacity's Git course.
Upvotes: 1
Views: 1101
Reputation: 77023
git add .
will also work fine, as long as you run it from your project's root directory.
The steps you have followed above will work absolutely fine, though I would like to bring your attention to using a .gitignore
, which is much recommended.
Using the .gitignore
file, you can tell git to explicitly not track the files which match the patterns file, so that your various build files, editor files, binary content etc are not tracked.
In your current process, you would have added the .gitignore (and added and committed it) between step 1 and 3.
You can have a look at sample .gitignore
for Android on github.
Upvotes: 1
Reputation: 113
git add . would work just fine, is not necessary to use -A in that scenario. Actually you can see the same process you did on the github help page:
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
If you have any doubt about commands you can always go to git documentation:
http://git-scm.com/docs/git-add
Upvotes: 1