The git push command is used to upload content updates of local repository to remote repository.
You need to perform these three steps before you can push files from your local repository to remote repository:
- First add files using the git add . command. The dot " . " after git add command saves updates of multiple or all files for the next commit. However, you can also save updates of a single file using git add <file-name> command.
- Next, commit the changes using the git commit -m 'commit message' command.
- Push the commit to remote repository using the git push origin <remote-branch-name> command.
git add . git commit -m 'my commit message' git push origin develop
Note: If multiple developers are working on the same branch then you must make sure that your current local branch has the latest updates of its remote counterpart. Your updates will be rejected if the tip of your current branch is behind its remote counterpart. Therefore, it is recommended that you update your current local branch before pushing it to the remote branch using the git pull origin <remote-branch-name> command.
git pull origin develop
After pulling updates from the remote branch, sometimes conflicts may arise if two or more separate branches have made edits to the same file when working in a team environment. Git will marked the files as being conflicted and will not let you push your updates to its remote counterpart. It is then your responsibility to resolve the conflicts.