Note: This is my first attempt to use Git.Steps shared below is the basic setup .And i find that git local and remote repo is quite interesting feature.
|=======================|
| Production(Code) Repo |
|=======================|
||
\/
|==============|
| Local(Co) Repo |
|==============|
||
\/
|===================|
| Local development |
|===================|
As per development requirement required a setup in which
i)without copy and pasting files
ii)needed a local commit(For local backup)
iii)and when okay with the code then deploy it to the main server.
(In my case directory is in /repo)
So,First set the remote (main/master) repository(My remote repository is in some remote location
#Needed to create <name>.git
>mkdir /repo/code.git
>cd /repo/code.git
>git --bare init
In local repository
>mkdir /repo/co.git
>cd /repo/co.git
>git --bare init
>git remote add origin ssh://<name>@<host>/repo/code.git
Development code
>cd /var/www
>git clone /repo/co.git co
>cd co
>git pull origin master
Now in development code
>cd /var/www/co
>echo "abc" > test
>git add test
>git commit -m "First commit"
>git push origin master
If you have to check the local commit works or not
>mkdir /var/www/co1
>cd /var/www
>git clone /repo/co.git co1
>cd co1
>git pull origin master
#---You will see the file there means
Now send this commit to main directory
>cd /repo/co.git
>git push origin master
#---If key based authenticaiton not there then it will ask for password
Now after that you can just pull remote server directory anywhere.So,Local repo is the local repository where you can commit any time and can pull from remote server and can accept push from local directory.
|=======================|
| Production(Code) Repo |
|=======================|
||
\/
|==============|
| Local(Co) Repo |
|==============|
||
\/
|===================|
| Local development |
|===================|
As per development requirement required a setup in which
i)without copy and pasting files
ii)needed a local commit(For local backup)
iii)and when okay with the code then deploy it to the main server.
(In my case directory is in /repo)
So,First set the remote (main/master) repository(My remote repository is in some remote location
#Needed to create <name>.git
>mkdir /repo/code.git
>cd /repo/code.git
>git --bare init
In local repository
>mkdir /repo/co.git
>cd /repo/co.git
>git --bare init
>git remote add origin ssh://<name>@<host>/repo/code.git
Development code
>cd /var/www
>git clone /repo/co.git co
>cd co
>git pull origin master
Now in development code
>cd /var/www/co
>echo "abc" > test
>git add test
>git commit -m "First commit"
>git push origin master
If you have to check the local commit works or not
>mkdir /var/www/co1
>cd /var/www
>git clone /repo/co.git co1
>cd co1
>git pull origin master
#---You will see the file there means
Now send this commit to main directory
>cd /repo/co.git
>git push origin master
#---If key based authenticaiton not there then it will ask for password
Now after that you can just pull remote server directory anywhere.So,Local repo is the local repository where you can commit any time and can pull from remote server and can accept push from local directory.
No comments:
Post a Comment