|
|
| (5 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| [[Category:Git]] | | #REDIRECT [[Move Uncommited Changes In Git To A Different Computer]] |
| == Goal ==
| |
| | |
| Work on code changes on multiple workstations without pushing changes to central GitHub repo.
| |
| | |
| == Workflow ==
| |
| | |
| Clone the repo to the the local network server that will serve as a localized hub.
| |
| | |
| This Git repo must be "bare" in order to accept pushes.<ref>[http://www.bitflop.dk/tutorials/git-bare-vs-non-bare-repositories.html Git bare vs non-bare repositories] BitFlop Tutorials</ref>
| |
| | |
| <syntaxhighlight lang="bash">
| |
| $ cd //myserver/develop/path/to/repo_parent_dir/ # (windows)
| |
| $ # or
| |
| $ cd ~/remote/myserver_share/path/to/repo_parent_dir/ # (mac)
| |
| $ git clone --bare -l https://github.com/username/myrepo.git myrepo
| |
| </syntaxhighlight>
| |
| | |
| === Windows ===
| |
| | |
| Now on a separate windows workstation create a remote for that local hub:
| |
| | |
| <syntaxhighlight lang="powershell">
| |
| > git remote add remotehubname x:\path\to\myrepo
| |
| > git push remotehubname master
| |
| </syntaxhighlight>
| |
| | |
| === Mac ===
| |
| | |
| Mount the shared directory where the hub repo is located.
| |
| | |
| <syntaxhighlight lang="bash">
| |
| # optionally create a remote for the local hub
| |
| $ git push /Volumnes/sharename/path/to/myrepo master
| |
| </syntaxhighlight>
| |
| | |
| === Migrating changes from a Mac workstation to a Windows workstation ===
| |
| | |
| * `ssh` to the mac: `ssh user@mac-name.local`
| |
| * (optional) Mount the shared network directory hosting the local git hub repo, if it is not already mounted.
| |
| ** `sudo mount -t smbfs //user:password@server/share_name path/to/mount`
| |
| ** The mount point must be an existing directory. It's necessary to create the directory before executing `mount` if the directory does not exist.
| |
| ** Working with the convention of creating mount points in the `~/remote/` directory.
| |
| * `cd` to git repo directory
| |
| * (optional) Create a remote for the local git hub if one does not already exist.
| |
| ** Check the existing remotes with `git remote -v`
| |
| ** Create remote with `git remote add remote_alias path/to/remote/repo`
| |
| * Add any modified files to a branch that is not `master`.
| |
| * Commit the branch.
| |
| * Push the branch to the hub repo on the local network: `git push remote_alias branch_name`
| |
| * Now on the Windows workstation it's possible to pull the changes in the working branch.
| |
| * `cd` to the local git repo on the Windows workstation.
| |
| * Sync up the master branch: `git pull origin master`
| |
| * (optional) View the branches on the local network hub: `git remote show remote_alias`
| |
| * Create the working branch on the Windows workstation if it doesn't already exist.
| |
| * Sync up the working branch: `git pull remote_alias branch_name`
| |
| | |
| == Notes ==
| |
| <references />
| |