I pushed latest codes from my GitLab repository. The changes was coming from my local development machine. I've successfully done it using this commands:
git push
to push my latest changes to my GitLab repository. Now I pulled the updates on server but unfortunately it did not happen successfully since I have uncommitted changes from the server.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .htaccess
modified: composer.json
modified: composer.lock
Untracked files:
(use "git add <file>..." to include in what will be committed)
php.ini
php_errorlog
These changes makes my git pull failed thus need to commit it first before pulling the updates from GitLab repository. How should we commit it the right way to prevent conflict on server side.
This is actually the scenario:
First I push my changes from local development machine to Gitlab repository. git command git push
Second I pull code updates from Gitlab repository to my server. git command git pull
Third I get conflict due to uncommitted changes in server. Error conflict: after done the second step.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .htaccess
modified: composer.json
modified: composer.lock
Untracked files:
(use "git add <file>..." to include in what will be committed)
php.ini
php_errorlog
NOTE: If multiple people are working on the same file, then there is more possibility of getting conflicts. It will be easy to resolve conflicts with Visual Studio Code Editor
Steps to resolve conflicts
git add.
git status
and validate once like whether the required file only got staged up.git stash
, which will store your current code with another indexgit pull
to pull the changes from the server, which will make your current working repository latest with servergit stash pop
, this will stash the changes which you have doneAccept Both
, if only your changes needed - do Accept Incoming
, if the current changes present in server is needed - Accept Current
.git status
, by this you can reverify whether only your changeset is correctHope this would be helpful
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.