1

I have a new java project and want to push it on local repository on my pc(Not github or remote)for first time.
I used these commands
1: git init
2: git add .
3: git commit
4: git push

I pushed it successfully but just want to know what is this repository address(path) to clone or put it in other place?
thanks

Sajad NasiriNezhad
  • 699
  • 1
  • 7
  • 27
  • 1
    what do you mean? the easiest way is to create a repo in your remote repository, and clone it to your drive. Why wouldn't you do it like that? – Stultuske Jun 14 '21 at 06:00
  • 4
    `git push` didn't do anything as you never set up a remote. – tkausl Jun 14 '21 at 06:01
  • Does this answer your question? [How to clone a local repository?](https://stackoverflow.com/questions/47922751/how-to-clone-a-local-repository) – KnockingHeads Jun 14 '21 at 06:03
  • See this also about how to push to remote if it does not exist. https://stackoverflow.com/questions/11382565/how-to-git-push-to-remote-if-remote-does-not-exist-at-all – KnockingHeads Jun 14 '21 at 06:13

2 Answers2

0

The basic operations of Git are established in remote warehouses, local warehouses, temporary storage areas, and workspaces. Your actions as above

  1. git init The git init command initializes a local warehouse
  2. git add . Temporarily store files in the current workspace to the temporary storage area
  3. git commitgit commit submits the staging area data to the local warehouse
  4. git push git push submits the local warehouse data to the remote warehouse

The following is a very intuitive picture

Command flow diagram

As shown in the figure, you can only pull and merge local warehouse data into the local workspace.

According to your needs, you can only build a git server locally, and you can access your locally built service through your ip address in the local area network.

qingmu
  • 402
  • 2
  • 12
  • I used these commands, but i don't know what is repository path to clone it on other place. – Sajad NasiriNezhad Jun 14 '21 at 06:32
  • You must set up a local git service. At this time, your personal computer can act as a remote warehouse, and others can pull it through your ip, like a web application – qingmu Jun 14 '21 at 06:49
  • @JerryHsu you can only do a git push if there already is a remote in place. Your answer doesn't really answer the question – Stultuske Jun 14 '21 at 06:51
0

want to push it on local repository on my pc(Not github or remote)for first time.

Then you need to create an empty bare repository (meaning a Git repo without any checked out file), which will serve as a remote to push to:

cd C:\repos
git init --bare my_new_repo.git

cd C:\path\to\existing\Git\repository
git remote add origin file://C/repos/my_new_repo.git
git push -u origin main

what is this repository address(path) to clone or put it in other place?

it is using the local file protocol, hence its URL:

file://C/repos/my_new_repo.git
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250