Reputation: 892
I am new to GIT (starting from zero). I have read the most basic tutorial on git local repository and github.
Following are the codes executed so far:
username: is my user name mailId: is mail id
git config --global user.name "Username"
git config --global user.mail "mailId"
git init
git add file.txt
git status
git commit -m "Added first file"
git log
git diff file.txt
git diff --color file.txt
git log -p
git log -p --color
cat .git/config
ssh-keygen -t rsa -C "mailId"
cat .ssh/id_rsa.pub
ssh -T [email protected]
git push -u origin master
#
git remote add origin https://github.com/Username/myrepo.git
public key
ssh-rsa ********************************************************************************************** [email protected]
What I have done so far was on testing basis. Now I want all on real time basis.
Issues/Doubts::
I have myrepo as my local repository and copying all files/codes in here to send it across my github repository named as myrepo (same as local repository).
1) I want a different local git directory (where my code work space is defined, so I won't need to copy paste again and again); which I do not know how and what to do, temper with .git config file.
2) from the new local git directory, I want to push all files/folders to github.
how do I proceed further?
Upvotes: 1
Views: 92
Reputation: 11536
I don't use github but I do use git. This shouldn't make much difference to the answer.
1) I want a different local git directory (where my code work space is defined, so I won't need to copy paste again and again); which I do not know how and what to do, temper with .git config file.
If you have multiple repos, they should all push and pull from the same place (presumably the remote github repo). So when you use repo #1, you push your changes to github, and then when you go to use repo #2, you pull from github. This keeps #1 and #2 in sync.
So, if you created the github repo from the contents of repo #1 and you want to create repo #2, you want to clone the github repo, not #1. To do that:
git clone https://github.com/Username/myrepo.git
Should do it; the new repo will automatically have a remote account for this as origin (much like the one you added to #1). This is where my inexperience with github comes in, since all I've ever done is clone from public repos there. Normally, I would use an ssh://
connection to my server and this works for push and fetch (pull). Check that (i.e., git remote -v
in repo #2 should list somewhere to fetch from and push to, just as it does in #1).
2) from the new local git directory, I want to push all files/folders to github.
As just described, once you have this set up local repos #1 and #2 should work the same way (git pull/push origin
etc).
Upvotes: 1