Many people ask me how do I manage my work repositories since it is advisable to do all development on your PC and a headache to trace any change, from local repository to the test machine using scp or rsync each time a change is made. Fortunately, git has a easier way! The alternative is to add as a remote to a local git repository, a pushable remote repository residing on a sshable server. The steps are as follows:
//At the server's ssh
mkdir some_project
cd some_project/
git init
git checkout -b test #as we cannot push to a checked out branch at the server from our laptops.
//On my pc
git clone git/url/to/some_project.git
cd some_project/
#Add pushable repo. which we inited on the server, as a remote to this local repo.
git remote add remote_name user@remote.server:/path/to/GIT/repo/some_project/
#check if added
git remote -v
#Clear firewall to remote server, if needed
#push desired branch(es)(say master) to the init-ed blank repo on the remote server.
git push remote_name master
//At the server ssh prompt to see the changes
git checkout master
ls
Voila! There's all your work!
Next time, you make any changes, in a separate branch, you just need to perform the push step at your PC and checkout the new branch on your server :D
Next time, you make any changes, in a separate branch, you just need to perform the push step at your PC and checkout the new branch on your server :D
No comments:
Post a Comment