Answer the question
In order to leave comments, you need to log in
Git not pushing changes?
I am learning git. I decided to upload two files to the repository, initialized the directory and made
git add client.py server.py
git commit -m "echo server, firts commit"
git push -u origin master
mkdir socket
mkdir echo-server
cp client.py server.py socket/echo-server/
MacBook-Pro-ivan:socket_berkley ivan$ git add socket/
MacBook-Pro-ivan:socket_berkley ivan$ git commit -m "add directory socket"
MacBook-Pro-ivan:socket_berkley ivan$ git log
commit a0f25758147eb11e6439a607ed0f010b8037a8f7
Author: IvankoPo <[email protected]>
Date: Sun Aug 20 15:29:38 2017 +0300
add directory socket
commit 5fea3bb214b26d0170d0bbd70ca902460fecd45d
Author: IvankoPo <[email protected]>
Date: Sun Aug 20 15:17:22 2017 +0300
echo server, firts commit
git checkout 5fea3bb
git add # я понял что лоханулся надо было git add socket
Nothing specified, nothing added.
Maybe you wanted to say 'git add .'?
git commit -m "back to the first"
HEAD detached at 5fea3bb
Untracked files:
.idea/
nothing added to commit but untracked files present
MacBook-Pro-ivan:socket_berkley ivan$ git push -u origin master
Branch master set up to track remote branch master from origin.
Everything up-to-date
git add client.py server.py
MacBook-Pro-ivan:socket_berkley ivan$ git commit -m "back to the first state"
HEAD detached at 5fea3bb
Untracked files:
.idea/
nothing added to commit but untracked files present
MacBook-Pro-ivan:socket_berkley ivan$ git checkout master
error: The following untracked working tree files would be overwritten by checkout:
.idea/vcs.xml
Please move or remove them before you can switch branches.
Aborting
MacBook-Pro-ivan:socket_berkley ivan$ git checkout a0f2575
error: The following untracked working tree files would be overwritten by checkout:
.idea/vcs.xml
Please move or remove them before you can switch branches.
Aborting
MacBook-Pro-ivan:socket_berkley ivan$ git log
commit 5fea3bb214b26d0170d0bbd70ca902460fecd45d
Author: IvankoPo <[email protected]>
Date: Sun Aug 20 15:17:22 2017 +0300
echo server, firts commit
MacBook-Pro-ivan:socket_berkley ivan$ ls
client.py server.py
MacBook-Pro-ivan:socket_berkley ivan$ mkdir socket
MacBook-Pro-ivan:socket_berkley ivan$ cd socket/
MacBook-Pro-ivan:socket ivan$ mkdir echo-server
MacBook-Pro-ivan:socket ivan$ cd ../
MacBook-Pro-ivan:socket_berkley ivan$ ls
client.py server.py socket
MacBook-Pro-ivan:socket_berkley ivan$ cd client.py server.py socket/echo-server/
-bash: cd: client.py: Not a directory
MacBook-Pro-ivan:socket_berkley ivan$ cp client.py server.py socket/echo-server/
MacBook-Pro-ivan:socket_berkley ivan$ git status
HEAD detached at 5fea3bb
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: .idea/vcs.xml
deleted: client.py
deleted: server.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/inspectionProfiles/
.idea/misc.xml
.idea/modules.xml
.idea/socket_berkley.iml
.idea/workspace.xml
socket/
MacBook-Pro-ivan:socket_berkley ivan$ git add socket
MacBook-Pro-ivan:socket_berkley ivan$ git commit -m "add directory socket"
[detached HEAD 1cdab81] add directory socket
3 files changed, 6 insertions(+)
create mode 100644 .idea/vcs.xml
rename client.py => socket/echo-server/client.py (100%)
rename server.py => socket/echo-server/server.py (100%)
MacBook-Pro-ivan:socket_berkley ivan$ ls
socket
MacBook-Pro-ivan:socket_berkley ivan$ git push -u origin master
Branch master set up to track remote branch master from origin.
Everything up-to-date
MacBook-Pro-ivan:socket_berkley ivan$ git log
commit 1cdab81099a4f10650e10566b7816a1262397886
Author: IvankoPo <[email protected]>
Date: Sun Aug 20 15:51:31 2017 +0300
add directory socket
commit 5fea3bb214b26d0170d0bbd70ca902460fecd45d
Author: IvankoPo <[email protected]>
Date: Sun Aug 20 15:17:22 2017 +0300
echo server, firts commit
MacBook-Pro-ivan:socket_berkley ivan$ git status
HEAD detached from 5fea3bb
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: socket/echo-server/client.py
modified: socket/echo-server/server.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/inspectionProfiles/
.idea/misc.xml
.idea/modules.xml
.idea/socket_berkley.iml
.idea/workspace.xml
no changes added to commit (use "git add" and/or "git commit -a")
MacBook-Pro-ivan:socket_berkley ivan$ git add socket
MacBook-Pro-ivan:socket_berkley ivan$ git commit -m "add coments"
[detached HEAD 594bcb6] add coments
2 files changed, 25 insertions(+), 25 deletions(-)
rewrite socket/echo-server/client.py (87%)
rewrite socket/echo-server/server.py (77%)
MacBook-Pro-ivan:socket_berkley ivan$ git status
HEAD detached from 5fea3bb
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/inspectionProfiles/
.idea/misc.xml
.idea/modules.xml
.idea/socket_berkley.iml
.idea/workspace.xml
nothing added to commit but untracked files present (use "git add" to track)
MacBook-Pro-ivan:socket_berkley ivan$ git push -u origin master
Branch master set up to track remote branch master from origin.
Everything up-to-date
Answer the question
In order to leave comments, you need to log in
after rolling back to the previous revision, you changed the tree locally, it remained old on the server. to change the tree on the server it was necessary to do
git push --force, then the tree on the server will be overwritten and will be the same as the local one
The main problem is that you started changing the history of commits after you pushed them. Of course, if you are the only developer in the project or this is your personal feature branch that no one rules except you, then it will do. But if you do this with project branches that other developers are working on, then you will get a lot of problems.
Read more:
https://git-scm.com/book/en/v1/%D0%92%D0%B5%D1%82%...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question