Single developer working on same code using 2 laptops ?

Phen8210

High Supremacy Member
Joined
Jul 29, 2011
Messages
28,971
Reaction score
8,267
That's the point, don't want to sync. Google drive only allows you to select the top level project, meaning the node_modules get sync as well.

Don't use google/one drive to sync codebase, i already tried it last time. I think it will mess you up more than help you out lol.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,300
By remote repo, he means setting it up on his home laptop as the remote repo, which is where he codes and commits. Why else would that option be considered?

Having it set up on a different device would break the purpose altogether. That is why i said to just keep it simple, setup on existing environment, don't need to change to linux or use whatever raspberri pi because that would break the purpose altogether.

I'm not here to find fault at you, but there's always a reason for people to ask certain questions.

In the end, it's still related about the discussion to this topic. :)

If you say so :)
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,300
I'm not getting it... The articles talks about setting up a remove "empty" repos, right ? And local, I add a remote definition like origin,etc....

git remote add name-of-repo userna5@desination:/home/userna5/production.git

I don't need to set up more like having some kind of daemon or listener at the remote to listen for the git push ? Who is serving the request at the remote ?

I don't have a remote machine to test this... may be later, i try localhost and see...

There is nothing so special about git. it is all just tooling.

SSH is the conduit to communicate securely with a remote server. It uses git on the server end to communicate via the SSH tunneling to your git client on your own system/client end.

Most git articles out there uses HTTPS, but actually just SSH is more than enough. The git client is capable of communicating to remote servers via SSH protocol.

You can even keep SSH connection alive if you know how, hence each time you push or pull from linux box don’t even need to reopen TCP connections.

Read up on ansible and you will understand. Ansible uses SSH and python on both ends to control remote servers, there is no daemon running at the server end, just a copy of python.

:)
 

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119
There is nothing so special about git. it is all just tooling.

SSH is the conduit to communicate securely with a remote server. It uses git on the server end to communicate via the SSH tunneling to your git client on your own system/client end.

Most git articles out there uses HTTPS, but actually just SSH is more than enough. The git client is capable of communicating to remote servers via SSH protocol.

You can even keep SSH connection alive if you know how, hence each time you push or pull from linux box don’t even need to reopen TCP connections.

Read up on ansible and you will understand. Ansible uses SSH and python on both ends to control remote servers, there is no daemon running at the server end, just a copy of python.

:)

THanks a lot ! THere is gap in my knowledge. I will read up on Ansible.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,300
I'm not getting it... The articles talks about setting up a remove "empty" repos, right ? And local, I add a remote definition like origin,etc....

git remote add name-of-repo userna5@desination:/home/userna5/production.git

I don't need to set up more like having some kind of daemon or listener at the remote to listen for the git push ? Who is serving the request at the remote ?

I don't have a remote machine to test this... may be later, i try localhost and see...
Some simple instructions to get you started

First establish SSH connection your own local system with the target system using private keys instead of password. It will make SSH a lot simpler and also make it possible to for GIT tool to SSH to the remote server without keep on needing to type in the credentials.
Refer to https://www.digitalocean.com/commun...sh-key-based-authentication-on-a-linux-server for instructions on how to do it.

So now I have the remote server in my example is
ubuntu@dksg_colony, below is how I setup my git repository in the remote server
Code:
ubuntu@dksgcolony:~$ mkdir WORK
ubuntu@dksgcolony:~$ cd WORK
ubuntu@dksgcolony:~/WORK$ mkdir special_project
ubuntu@dksgcolony:~/WORK$ cd special_project/
ubuntu@dksgcolony:~/WORK/special_project$ git init --bare
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:     git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:     git branch -m <name>
Initialized empty Git repository in /home/ubuntu/WORK/special_project/
ubuntu@dksgcolony:~/WORK/special_project$ ls -al
total 40
drwxrwxr-x 7 ubuntu ubuntu 4096 May 13 18:38 .
drwxrwxr-x 3 ubuntu ubuntu 4096 May 13 18:38 ..
-rw-rw-r-- 1 ubuntu ubuntu   23 May 13 18:38 HEAD
drwxrwxr-x 2 ubuntu ubuntu 4096 May 13 18:38 branches
-rw-rw-r-- 1 ubuntu ubuntu   66 May 13 18:38 config
-rw-rw-r-- 1 ubuntu ubuntu   73 May 13 18:38 description
drwxrwxr-x 2 ubuntu ubuntu 4096 May 13 18:38 hooks
drwxrwxr-x 2 ubuntu ubuntu 4096 May 13 18:38 info
drwxrwxr-x 4 ubuntu ubuntu 4096 May 13 18:38 objects
drwxrwxr-x 4 ubuntu ubuntu 4096 May 13 18:38 refs
ubuntu@dksgcolony:~/WORK/special_project$

Now on my local system (I'm using Mac OS X)
Code:
Enterprise:WORK davidktw$ git clone ssh://dksg_colony/~/WORK/special_project
Cloning into 'special_project'...
warning: You appear to have cloned an empty repository.
Enterprise:WORK davidktw$ cd special_project/
Enterprise:special_project davidktw$ ls -al
total 0
drwxr-xr-x    3 davidktw  staff    96 May 13 18:39 .
drwxr-xr-x  148 davidktw  staff  4736 May 13 18:39 ..
drwxr-xr-x    9 davidktw  staff   288 May 13 18:39 .git
Enterprise:special_project davidktw$ echo abc > abc
Enterprise:special_project davidktw$ git add .
Enterprise:special_project davidktw$ git commit -m 'Initial Commit'
[master (root-commit) c475dc6] Initial Commit
 1 file changed, 1 insertion(+)
 create mode 100644 abc
Enterprise:special_project davidktw$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 216 bytes | 216.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To ssh://dksg_colony/~/WORK/special_project
 * [new branch]      master -> master
Enterprise:special_project davidktw$

On the same local system in a different direction, I clone out the project again
Code:
Enterprise:WORK2 davidktw$ git clone ssh://dksg_colony/~/WORK/special_project
Cloning into 'special_project'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
Enterprise:WORK2 davidktw$ ls
special_project
Enterprise:WORK2 davidktw$ cd special_project/
Enterprise:special_project davidktw$ ls -al
total 8
drwxr-xr-x   4 davidktw  staff  128 May 13 18:41 .
drwxr-xr-x   3 davidktw  staff   96 May 13 18:41 ..
drwxr-xr-x  12 davidktw  staff  384 May 13 18:41 .git
-rw-r--r--   1 davidktw  staff    4 May 13 18:41 abc
Enterprise:special_project davidktw$

That's all you need, nothing so difficult and special. Linux, GIT, SSH
Other than GIT, which you can easily install using from the distro repo using APT/YUM/PACMAN or whatsoever, probably install OPENSSH if for whatever reason your linux box doesn't have it installed (mostly unlikely), the instructions to get started is straight forward and easy.

Sometimes technology is this easy, but a lot of people tend to complicate things with all the bells and whistles which are good to have, but not essential. Get the basics working and learn the decorations as and when you need.

Like to backup your remote recon periodically ? Simple, setup the cronjob to run
Code:
tar -czf special_project-`date +'%s'`.tar.gz ~/WORK/special_project
as often as you like
Easy ?

Others things like pruning the backup files, move the backup tar files to AWS S3, deduplication and more can be learn as you advance on these knowledges.

:)
 
Last edited:

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119
Some simple instructions to get you started

First establish SSH connection your own local system with the target system using private keys instead of password. It will make SSH a lot simpler and also make it possible to for GIT tool to SSH to the remote server without keep on needing to type in the credentials.
Refer to https://www.digitalocean.com/commun...sh-key-based-authentication-on-a-linux-server for instructions on how to do it.

So now I have the remote server in my example is
ubuntu@dksg_colony, below is how I setup my git repository in the remote server
Code:
ubuntu@dksgcolony:~$ mkdir WORK
ubuntu@dksgcolony:~$ cd WORK
ubuntu@dksgcolony:~/WORK$ mkdir special_project
ubuntu@dksgcolony:~/WORK$ cd special_project/
ubuntu@dksgcolony:~/WORK/special_project$ git init --bare
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:     git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:     git branch -m <name>
Initialized empty Git repository in /home/ubuntu/WORK/special_project/
ubuntu@dksgcolony:~/WORK/special_project$ ls -al
total 40
drwxrwxr-x 7 ubuntu ubuntu 4096 May 13 18:38 .
drwxrwxr-x 3 ubuntu ubuntu 4096 May 13 18:38 ..
-rw-rw-r-- 1 ubuntu ubuntu   23 May 13 18:38 HEAD
drwxrwxr-x 2 ubuntu ubuntu 4096 May 13 18:38 branches
-rw-rw-r-- 1 ubuntu ubuntu   66 May 13 18:38 config
-rw-rw-r-- 1 ubuntu ubuntu   73 May 13 18:38 description
drwxrwxr-x 2 ubuntu ubuntu 4096 May 13 18:38 hooks
drwxrwxr-x 2 ubuntu ubuntu 4096 May 13 18:38 info
drwxrwxr-x 4 ubuntu ubuntu 4096 May 13 18:38 objects
drwxrwxr-x 4 ubuntu ubuntu 4096 May 13 18:38 refs
ubuntu@dksgcolony:~/WORK/special_project$

Now on my local system (I'm using Mac OS X)
Code:
Enterprise:WORK davidktw$ git clone ssh://dksg_colony/~/WORK/special_project
Cloning into 'special_project'...
warning: You appear to have cloned an empty repository.
Enterprise:WORK davidktw$ cd special_project/
Enterprise:special_project davidktw$ ls -al
total 0
drwxr-xr-x    3 davidktw  staff    96 May 13 18:39 .
drwxr-xr-x  148 davidktw  staff  4736 May 13 18:39 ..
drwxr-xr-x    9 davidktw  staff   288 May 13 18:39 .git
Enterprise:special_project davidktw$ echo abc > abc
Enterprise:special_project davidktw$ git add .
Enterprise:special_project davidktw$ git commit -m 'Initial Commit'
[master (root-commit) c475dc6] Initial Commit
 1 file changed, 1 insertion(+)
 create mode 100644 abc
Enterprise:special_project davidktw$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 216 bytes | 216.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To ssh://dksg_colony/~/WORK/special_project
 * [new branch]      master -> master
Enterprise:special_project davidktw$

On the same local system in a different direction, I clone out the project again
Code:
Enterprise:WORK2 davidktw$ git clone ssh://dksg_colony/~/WORK/special_project
Cloning into 'special_project'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
Enterprise:WORK2 davidktw$ ls
special_project
Enterprise:WORK2 davidktw$ cd special_project/
Enterprise:special_project davidktw$ ls -al
total 8
drwxr-xr-x   4 davidktw  staff  128 May 13 18:41 .
drwxr-xr-x   3 davidktw  staff   96 May 13 18:41 ..
drwxr-xr-x  12 davidktw  staff  384 May 13 18:41 .git
-rw-r--r--   1 davidktw  staff    4 May 13 18:41 abc
Enterprise:special_project davidktw$

That's all you need, nothing so difficult and special. Linux, GIT, SSH
Other than GIT, which you can easily install using from the distro repo using APT/YUM/PACMAN or whatsoever, probably install OPENSSH if for whatever reason your linux box doesn't have it installed (mostly unlikely), the instructions to get started is straight forward and easy.

Sometimes technology is this easy, but a lot of people tend to complicate things with all the bells and whistles which are good to have, but not essential. Get the basics working and learn the decorations as and when you need.

Like to backup your remote recon periodically ? Simple, setup the cronjob to run
Code:
tar -czf special_project-`date +'%s'`.tar.gz ~/WORK/special_project
as often as you like
Easy ?

:)

Thanks... I try...
 

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,300
got me thinking...
Windows got scheduler. I think can also set to run a batch when idle. Set VSCode to auto-save.
Then for git, squash the commit to get the latest commit each time... wow... I think sometime along the way, the thing will break and all my codes corrupted...:)

Like i have already told you right from the beginning, GIT is not a syncing tool. If you want to sync something, sync using dropbox, or some other tools like rsync. I only suggested these because of your use case, where you sync and then u work between home and office. It is not meant to resolve quick syncing between multiple parties across multiple sites.

Nothing will break with git commit and push, just that conflicts may occur if one is “collaborating” and that is why git, subversion and other code control systems exists. These are collaboration tools, not syncing tools. Otherwise a simple rsync works better and more straightforward.

:)
 

kukathe

Junior Member
Joined
Aug 2, 2007
Messages
82
Reaction score
24
or... just use USB drive? or even Windows To Go (if you are windows user)?
 

Trader11

Banned
Joined
Oct 14, 2018
Messages
15,698
Reaction score
5,233
Sync directory using dropbox, or icloud drive, or any other such techniques. Normally you can exclude directories from syncing.

Git is not a syncing tool, it is a collaboration tool. Pushing into the origin repo is the action to collaborate. What you do on your local repo is just for yourself. Your use case to use it as a syncing mechanism is a side effect if you pull the origin repo into your another local repo residing elsewhere. These actions are explicit for the user to control what and when to collaborate, not a syncing operation.

:)
The question is whether it is secure to do that? Why let your developer access company code in their personal laptop?
 

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119
The question is whether it is secure to do that? Why let your developer access company code in their personal laptop?

Not office codes... won't use personal laptop to do office codes. usually self-study online courses. You do self-study evening, weekends and before office hours or lunch time. If you don't want to lug your office laptop back everyday, then you need to synch your codes.
 

Trader11

Banned
Joined
Oct 14, 2018
Messages
15,698
Reaction score
5,233
Not office codes... won't use personal laptop to do office codes. usually self-study online courses. You do self-study evening, weekends and before office hours or lunch time. If you don't want to lug your office laptop back everyday, then you need to synch your codes.
Why not version control in GitHub?
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,300

GoodBetterBest

Supremacy Member
Joined
Jan 23, 2019
Messages
6,239
Reaction score
2,119
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
https://www.atlassian.com/git/tutorials/git-hooks

Implement your own local hooks, particularly post-commit to push after commit.
Basically this will make your git works more like subversion.
Subversion commit always push to the repo (equivalent to remote repo in git), there is no local commit in subversion.

Have fun.
:)

Don't need a post-commit... just write a *.bat to commit and push.

Reality is that if I can forget to push, then I also can forget to commit.

I've come to the conclusion that there is no solution for my requirement as I hoped. It's ok. I just live with it.

Thanks for all who replied.
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top