OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Issues connecting a local workspace to a GitHub repo and creating branches

  • Thread starter Thread starter Nick H
  • Start date Start date
N

Nick H

Guest
I'm trying to connect a local workspace to an identical repository on GitHub. In this instance, I cannot use git clone so I'm trying to find a work-around. I seem to be able to set the remote url fine, but normal git commands don't work as expected for me afterwards.

To start, I ran the following commands:

Code:
git init
git remote set-url origin [my SSH clone path]
git fetch

Those commands run fine and without error. When I run git remote -v it returns the expected repo path for fetch/push and git branch -a returns the expected list of remote branches. If I run git checkout -b main it returns Switched to a new branch 'main', but git branch returns nothing. I would expect this command to switch me to that local branch (which points to the remote repo branch). If I try doing git pull origin main it says all of my local files will be overwritten (when they match the incoming pull completely). If I run git branch main, instead of creating a new branch, I get fatal: not a valid object name: 'main'. I've never had any issues using the commands mentioned with more traditionally cloned repos. Any insight or suggestions would be appreciated.
<p>I'm trying to connect a local workspace to an identical repository on GitHub. In this instance, I cannot use <code>git clone</code> so I'm trying to find a work-around. I seem to be able to set the remote url fine, but normal git commands don't work as expected for me afterwards.</p>
<p>To start, I ran the following commands:</p>
<pre><code>git init
git remote set-url origin [my SSH clone path]
git fetch
</code></pre>
<p>Those commands run fine and without error. When I run <code>git remote -v</code> it returns the expected repo path for fetch/push and <code>git branch -a</code> returns the expected list of remote branches.
If I run <code>git checkout -b main</code> it returns <code>Switched to a new branch 'main'</code>, but <code>git branch</code> returns nothing. I would expect this command to switch me to that local branch (which points to the remote repo branch). If I try doing <code>git pull origin main</code> it says all of my local files will be overwritten (when they match the incoming pull completely). If I run <code>git branch main</code>, instead of creating a new branch, I get <code>fatal: not a valid object name: 'main'</code>. I've never had any issues using the commands mentioned with more traditionally cloned repos. Any insight or suggestions would be appreciated.</p>
Continue reading...
 

Latest posts

M
Replies
0
Views
1
Mohit Pant
M
Top