Reputation: 63
$ git status
On branch Palak_Assignment27 Your branch is up to date with 'origin/Palak_Assignment27'.
Changes to be committed: (use "git restore --staged ..." to unstage) renamed: src/palakSJun20/MethodOverloadingConcept.java -> src/palakSJun20/MeetingRoom.java
Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: src/palakSJun20/MeetingRoom.java
$ git push
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 4 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 1.46 KiB | 374.00 KiB/s, done.
Total 5 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), completed with 3 local objects. remote: This repository moved. Please use the new location:
Upvotes: 1
Views: 7039
Reputation: 3950
remote: This repository moved. Please use the new location:
This actually seems unrelated to your file move/rename. It says the "origin" repository location has changed.
Compare your git remote get-url origin
to the "new location" specified by the message and correct it with git remote set-url origin <new address>
(replace <new address>
with the new location specified by the reply).
After that you should be able to push again.
With regards to the file being renamed: Based on your git status
output it seems you didn't even commit that rename yet. So it wouldn't be pushed anyway.
However if you want to stage your file changes for commit use git add -p
and say y
(yes) to the changes you want to add to the commit.
After that you can verify the changes prepared for commit with git diff --staged
(you may have to use page up/down to look at changes and to press q
key to quit looking at it).
If everything looks alright use git commit
to create the commit.
After that you may want to double-check your commit by looking at it with git show
.
If your commit looks the way you want, use git push origin HEAD
to push your locally created commit(s) to the origin repository.
(The "origin HEAD" part makes sure you only push the current branch, not all of them)
However, as mentioned above it seems your repository ("origin") has moved, so you will have to adjust its address before you can push.
Upvotes: 1
Reputation: 30204
You could tell git to remove it (after the fact) and then add the new file.
git rm original-file-path
git add new-path
Upvotes: 1
Reputation: 150
Your git status says that you have changes not staged for commit.
You need to run git add src/palakSJun20/MeetingRoom.java
, then create a commit, push it ...
The easiest way is to rename a file is by using git itself.
git mv MethodOverloadingConcept.java MeetingRoom.java
Then you can commit the change using git commit
.
And then after you can push the new commit using git push
.
Upvotes: 2