I Need Help With Some GitHub Questions, Please.

Started by
2 comments, last by Bregma 5 years, 7 months ago

I used GitHub Desktop with Visual Studio and I have a working remote repo on GitHub (at last!)  

 
Now I would like to move the remote URL from : 
https://www.github.com/Joshei/MyBuild.git to a brand new remote repo: https://www.github.com/Joshei/MyGolfRepo.git.
 

I have done some research and I think this is what I need to do with the new URL: 

git config remote.origin.url https://github.com/abc/abc.git 

follow this up with:  git push origin master? 

Is this correct?

I have a few concerns. 


Firstly, in the first command is:   git config remote.origin.url   literal (typed exactly as it is shown there?) 

Second, if the second statement is true how is it written, exactly? 

Third, Should I use git bash or git cmd? 

And fourth, when using the above tool, where do I navigate to, to run the commands? 

Of course, I want to do this in a safe manner.  I am concerned that since the old (present) repo already has some history on it there could be problems moving it over to the new address. 
  
Thank you, as you can see I have little experience with Github. 
 

Josheir 
  
There are possible suggestions that the above can be accomplished by changing the local git/config.  Is this another way, and would I still need the second statement?  I am very interested in both ways because it would be highly appreciated.   

Thanks again! 
  
 

 

Advertisement

Yes, `git config remote.origin.url` and `git push origin master` is more or less correct, except for a small caveat:  The destination repository,`Joshei/MyGolfRepo.git`, already   has a commit.  You will need to force update in order to effectively replace the destination repository with the source repository. 

  • Remotes can also be managed with `git remote`: https://git-scm.com/docs/git-remote.
  • On git bash vs git cmd:  It doesn't matter too much.  `git bash` is Bourne shell for Windows with some emulated Linux features: https://superuser.com/a/1053657.  I use Git SCM under Powershell and work around Windows-specific issues (`GIT_SSH`, for example).
  • On where to be:  Git looks for the first directory containing the git object database, the `.git` folder, and operates from there.  I generally manage git from the topmost project directory.
  • On backups:  If you have concerns about possibly losing data in your local repository, then make a backup of your local `.git` folder, and move it outside of the repository directory.  If something goes very wrong, you can always remove your current `.git` folder and replace it with a copy of the backup.


As an aside, I recommend anyone learning git to use a repository visualizer such as gitk (Git SCM), TortoiseGit, or even git log, and follow along as you execute your git commands.

Maybe it's because you're using a GUI, but you seem to be overcomplicating things.  Git was made by a very lazy developer for what he considered idiots; don't second guess it.

If you were on the command line, you would use two commands.  First, add a remote repo named 'github'.
 


git remote add github https://www.github.com/Joshei/MyGolfRepo.git.

Them push to it.


git push github master

The git command line is verb-object-subject, which is a little confusing for native English speakers, but these days is fairly consistent.

Other than setting your name and email, you generally never have to mess with git internals, like anything using 'git config'.  I guess you'll have to spend a lot of time playing with the GUI to figure out which 1000 words of picture it takes to do the action of two command, though.  Good luck.

Stephen M. Webb
Professional Free Software Developer

This topic is closed to new replies.

Advertisement