Cloning Repository - visual-studio-2010

I have installed GIT on VS2010
I am comfused with tools of GIT.
When clicking on:
GIT->Clone Repository
Does cloning repository means that we will upload files of the repository?
Is Commit tool the opposite way of cloning: uploading files in the repository?

Yeah, cloning mean you download the files of your repository.
Commit is a tool to save your modifications, but to upload file into your repository, you need to use the Push tool

Related

Push current code to existing GitHub repository

I have several Visual Studio solutions that have both a local repository and one on GitHub. I've already made many changes and successfully pushed those changes to GitHub.
But now Visual Studio has forgotten that one of my local repositories is associated with a GitHub repository and I can't seem to figure out how to reconnect it. In fact, it no longer lists that repository in my list of GitHub repositories.
In the image below, you can see I have a local repository called Toxic, but that repository does not appear in the list of GitHub repositories. If I try publishing the Toxic project to GitHub, it just tells me the repository already exists.
How the heck can I get all of my existing Github repositories to show up in the top section shown above so I can push my latest changes?
it appears the only option is to clone the GitHub repository locally, copy my modified files over the newly created repository, and then check in my changes.
Try fist:
installing Git for Windows (command-line)
cloning your remote repo in a new folder
adding your existing repository as a remote
fetching and see if you can cherry-pick your commits
That is:
git clone https://github.com/<user>/<repo> newFolder
cd newFolder
git remote add old ../path/to/old/local/repo
git fetch old
git log old/master
git cherry-pick old-sha1..old/master
(with old-sha1 being the first commit you want back)
Then add the newFolder in your Visual Studio workspace, and see if everything works (do a modification, add, commit and push)
Unless I'm missing something, it appears the only option is to clone the GitHub repository locally, copy my modified files over the newly created repository, and then check in my changes.
Of course, I lose all my comments and iterations since the last check in to GitHub. And care had to be taken not to delete the .git folder, and to copy over all changed file and delete any that had been removed. Seems like there should be an easier way but this certainly did the trick.
I'm no git expert, but I think I might be able to help, if I'm not too late.
Run:
git remote -v
This should print something in the form of:
origin <remote_repo_url> (fetch)
origin <remote_repo_url> (push)
If you only see:
origin (fetch)
origin (push)
try running:
git remote set-url origin <remote_repo_url>
If you get no output then run:
git remote add origin <remote_repo_url>
And then try
git push -u origin
The -u or --set-upstream flag will set origin as the default repo for your branches.

How to check the URL of current git repository with TortoiseGit?

I am new to git and have currently switched from Bitbucket to Github, but have not yet deleted the Bitbucket repository. I have a folder in my computer, but am unsure whether that folder is from the github or the bitbucket repository. Is there a way I can check the URL of the repository with TortoiseGit, and if so how?
Go to your project folder and open the .git/config file. There you can see the remote urls.
Git is a decentralized version control system and, thus, can have multiple remote repositories for a working tree.
The configured ones can be seen in TortoiseGit settings -> Git -> Remotes (cf. https://tortoisegit.org/docs/tortoisegit/tgit-dug-settings.html#tgit-dug-settings-remote).
I think that in the 'fetch' dialog, there is a 'manage remotes' link.

Reinitializing a git repository

I have an xcode project on my desktop in a directory that originally had a git repository with a tracking branch that tracked a remote branch on github. The remote branch has some 84 commits and is 2 commits ahead of the master branch of the project I'm adding features to. I changed the name of the folder/directory on my desktop. I'm not 100% sure if this is the reason why but when I go to git status I get: fatal: Not a git repository (or any of the parent directories): .git. My plan is to simply git Init, add the remote branch and create a new tracking branch and than commit locally to that branch and than push to the remote branch. However, I'm a git beginner and I'm not sure if this is the proper way to go about it. I'm very weary of losing any commit history or accidentally breaking something. Is the method I outlined a good way of rectifying this loss of the git repo?
If you have all your code updated in remote repo then your local .git is deleted. You don't need to re-init your local repo. Rather just clone it.
git clone remote_repo
If you don't have any commit in remote repo, Simply follow
git init
git add all_local_files
If you have updated remote repo than some commits made in local but not pushed and you lost .git. Simply clone remote. Add all files in a single commit
git clone
git add all_local_files
Looks like you messed up your git repository, but not the code / contents.
One way to restore and keep local changes ( if any ) would be:
Clone another copy of your repo from github.
Copy all modified files to the new repo, omitting removed ones: rsync -duztv /old/local/repo/ /new/local/repo
git status to see what the situation is.

Create git repository for existing project?

After a close call with deleting a swift file, I noticed that I did not have create the project with it to create a git repository. Is there a way to have an existing project start a git repository? Or do I have to start a new project and move all of my code/files over?
Yes, you can initiate a git repo for an existing project.
There are several ways to initiate and manage a Git repository over an existing project.
Preparations.
There are some files that are not subject to source control. Those are project files from your IDE, compiled classes and so on. To exclude them, get a .gitignore file and put it to the root directory of your project.
Creating a Git repo with command-line tool
go inside the project folder and create new git repository using:
cd path/to/your/project
git init
Then add your files
git add *
and then commit
git commit -am "Initial commit"
if you need to push it to GitHub/BitBucket use
git remote add origin [repository URL]
and then
git push origin master
Creating a Git repo with a gui-based tool or IDE.
You can as well use any gui-based tool. E.g., in IntelliJ IDEA use the menu [VCS] - [Import into version control] - [Create Git repository].
If you are going to use GitHub, there's a convenient GitHub client.

uploading code to github

I have created a repository named appengine-testers on github. It is a public repository. Though I easily managed to create a repository but I do not know how to store code there. Do I need to upload the code/folder ?
There are multiple options to do that, i'll just briefly tell the simple one.
git clone ssh-path-to-project
It creates .git folder in the project which is used for references.
cd project
copy the entire project code from any location and paste it in this folder.
Now
Add all the untracked files.
git add .
git commit -am <"commit message">
or
git commit -a
Which automatically takes the changes.Lastly
git push
It pushed the entire code to the repository
One more simple option is do
git init
in the project folder and then change the remote url in the .git folder created inside the project folder
Once you create the repo on github, it'll give you a URL (that looks kinda like git#github.com:yourusername/appengine-testers.git) with push access. From there, you just push from your local repo to that URL.
It's probably easier if you add that URL as a remote. Typically you'd call it 'origin'.

Resources