Skip to main content

Working with Git from Existing Repo to New Repo

  •  git clone existing repo in IDE 
    • git clone https://github.com/org/repo.git
  • make necessary changes in the files 
  • git remote -v
    • it list all the remote urls in the local system IDE
    • origin https://github.com/org/repo.git (fetch)
    • origin https://github.com/org/repo.git (push)
  • git rename existing origin url to new old-orign
    • git remote rename origin old-origin
  • git add new repo url to origin
    • git remote add origin https://github.com/org/repo2.git
  • verify origin urls
    • git remote -v
      • should get 4 urls 2 for old-origin(old repo) and 2 for (new repo) origin 
  • git reinitialize 
    • git init . 
      • Reinitialized existing Git repository in C:/repo/.git/
  • git add all files
    • git add .
  • commit the changes 
    • git commit -m "Initial"
  • git remove .idea files 
    • git rm -r --cached .idea 
  • removes already tracked files in git
    • rm -r .idea 
      • this deletes all .idea files including the folder locally
  • git push -u origin --all
  • git remote remove old-origin

Comments