How do I clone a git repository located on my Mac connected to the internet? - linux

I have an up-to-date git repo that I started on my MacBook. The project that I am working on is required to work on my university's Linux workstations that I can login to remotely via SSH. I've cded to the directory that I want to clone to on the workstation. I just have no idea how to get the SSH address for the repo on my MacBook when its connected to the internet. Also, how would this stay consistent considering I get a different IP every time I reconnect or go somewhere? Is what I'm doing even possible or a good idea?

One simple solution is to create an empty repository using a free github.com or bitbucket.org account. Using github for this example, you would then have a URL for the repo such as:
https://github.com/username/repo-name.git
Then, simply push the contents of your local repo up to the newly created online repo like so:
$ git remote add origin https://github.com/<username>/repo-name.git
$ git add --all
$ git commit -m 'initial commit'
$ git push -u origin master

Related

How to get the process when I use ssh to a remote server to git a repository?

I am from China, and for some reason git connect is very slow. I know how to use git proxy, but still not fast.
What I know and tried is to SSH to my VPS and download git repository in my VPS. and then I zip the repository fold and SCP the zip from in my local computer. In this way, finally I get my git repository which it very comfortable for my and it is fast!!!
Now I want to know, is there a simple command or shell to achieve this?
I cant handle it by typing every time but it is not effective.
scp relies on ssh. You can always clone the repository over ssh from your VPS. In one line you could do something like this:
$ ssh <VPS> git clone https://<project.git> && git clone ssh://VPS/<project.git>
Reference

Added BitBucket repo as remote on GitHub

I've just installed git on Ubuntu, now I want to work on my repo in BitBucket. I'm a little confused on how to do so. I can't do the following:
git remote add BitBucketRepo git#bitbucket.org:dir/file.git
As it returns the following error:
fatal: Not a git repository (or any of the parent directories): .git
It clearly is pointing to a git repo, so why is it lying to me?
Also, it is worth noting I am using SSH and I have successfully paired my GitHub account to my computer.
You need to run this command from a local git repository (a directory in which you have run git init or git clone) - otherwise git remote doesn't know which local repo you want to add the remote for.
It should be as simple as cd my-local-dir, where my-local-dir is the directory containing your local (cloned) git repository.
If you don't yet have the repo available locally:
git clone git#github.com:...etc... my-local-dir
cd my-local-dir
git remote add ButbucketRepo git#bitbucket.org...
git push -u ButbucketRepo master
This will clone your code from Github into the my-local-dir directory, add your BitBucket repo as a remote repository, push your code up to Bitbucket and set the local master branch to track the BitBucket remote's master branch.
Tracking means that commands that involve a remote like git push will automatically use the BitBucket remote's master branch. If you don't want that behaviour, skip the -u option.

view the git repository on remote linux server -> in Windows?

Problem: Need to view Git history visually in windows, repository is on remote Linux server (Ubuntu).
Question: What are two easy ways to view the git repository on remote linux server -> in Windows?
I have initially tried mirroring the remote mirror, then viewing it locally - updating when needed, but I get an error when connecting,
git clone --mirror username#serveraddress.com:/home/username/projectfolder
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Again I'm on Windows using Git Bash, trying to clone a remote repo that's on Linux.
Thanks in advance.
There is no importance where the repo resides.
As the error said,
1- make sure you have the address right
2- make sure you have access to the address

Git - Syncing a Github repo with a local one?

First off, forgive me if this is a duplicate question. I don't know anything but the basic terminology, and it's difficult to find an answer just using laymen's terms.
I made a project, and I made a repository on Github. I've been able to work with that and upload stuff to it for some time, on Windows. The Github Windows application is nice, but I wish there was a GUI for the Linux git.
I want to be able to download the source for this project, and be able to edit it on my Linux machine, and be able to do git commit -m 'durrhurr' and have it upload it to the master repository.
Forgive me if you've already done most of this:
The first step is to set up your ssh keys if you are trying to go through ssh, if you are going through https you can skip this step. Detailed instructions are provided at https://help.github.com/articles/generating-ssh-keys
The next step is to make a local clone of the repository. Using the command line it will be git clone <url> The url you should be able to find on your github page.
After that you should be able to commit and push over the command line using git commit -am "commit message" and git push
You can use SmartGit for a GUI for git on Linux: http://www.syntevo.com/smartgit/index.html
But learning git first on the command line is generally a good idea:
Below are some basic examples assuming you are only working from the master branch:
Example for starting a local repo based on what you have from github:
git clone https://github.com/sampson-chen/sack.git
To see the status of the repo, do:
git status
Example for syncing your local repo to more recent changes on github:
git pull
Example for adding new or modified files to a "stage" for commit
git add /path/file1 /path/file2
Think of the stage as the files that you explicitly tell git to keep track of for revision control. git will see the all the files in the repo (and changes to tracked files), but it will only do work on the files that you add to a stage to be committed.
Example for committing the files in your "stage"
git commit
Example for pushing your local repo (whatever you have committed to your local repo) to github
git push
What you need to do is clone your git repository. From terminal cd to the directory you want the project in and do
git clone https://github.com/[username]/[repository].git
Remember not to use sudo as you will mess up the remote permissions.
You then need to commit any changes locally, i.e your git commit -m and then you can do.
git push
This will update the remote repository.
Lastly if you need to update your local project cd to the required directory and then:
git pull
To start working on the project in linux, clone the repo to linux machine. Add the ssh public key to github. Add your username and email to git-config.
For GUI you can use gitg.
PS : Get used to git cli, It is worth to spend time on it.

how to create a virtual copy of git repo on a test server

I am fairly new to Git. I have worked locally, but today i need to setup a remote machine with the git. I have no idea how.
Basically my setup is like this.
I have a windows machine which has a vmware player installed, which is used to connect to the dev ubuntu linux machine where out Git repo is situated. I putty to the dev machine and do all the operation related to git with username common to all the developers username : dev
Now there is a new rollup that is created in the dev git repo which is required to be deployed on our ubuntu linux test server. I have my account in test server. username:ash.
What are the steps that should be followed to setup this. I have some time back had a discussion with one of my colleague who had shared about using SSH key. As he is the only contact person who is not available, I have no info how to proceed. I have created the SSH key.
login to the machine as "ash".
ash#gitserver:~$
create a new directory that will contain the git-repository
ash#gitserver:~$ mkdir rollout.git
change into the directory
ash#gitserver:~$ cd rollout.git
initialize the git repository
ash#gitserver:~/rollout.git$ git init --bare
go back to your dev machine and clone the newly created repository or add it to the "remote"s of an existing git repo. use "ssh://ash#gitserver/~/rollout.git" as the remote-url.
[update for cloning]: make sure that there is not already a "rollout" directory in the directory where you want to clone to. for simplicity, create an empty directory "foo/" and try to clone into that directory. you can then move the cloned repository to wherever you want to.
push changes to the new repository.......done!
the use of ssh-keys will make authentication simpler and/or more secure but is in no ways necessary (or related) to setting up the git repository.

Resources