Before making any changes to a Git repository, first make sure that you download the latest update from the remote repository on your branch. So, first go to the branch that you want to modify with this command, if you are not already on that branch:
git checkout BRANCH_NAME|
Next, download or fetch the latest changes of that branch from the remote repository to your local repository with this command:
git fetch --all -p|
Alternatively, you can download and merge from any branch from any remote repository to your local repository with this command:
git pull origin BRANCH_NAME|
Next, make your changes to your local repository.
If you want to create a new file in the repository or if you modified a file in the repository, then first add the file using this command (you can even use wildcards, if needed):
git add FILENAME [FILENAME2] ..|
If you want to rename a file or move a file to another directory in the same repository, then use this command:
git mv OLD_FILENAME NEW_FILENAME|
Finally, if you want to delete a file from a repository, then run this command (you can even use wildcards, if needed):
git rm FILENAME [FILENAME2] ..|
Now that you are done making changes to your repository, now you need to save your changes locally. So, you need to commit your changes like this:
git commit –m "commit remark"
If you leave out the commit remark, Git will open an editor (vim) and ask you to please enter a commit remark.
Finally, you need to push your commit from your local repository to your remote repository using this command:
git push origin BRANCH_NAME|
This may seem like a lot commands to execute just to make a simple change in a Git repository; but with a lot of practice, they will become second nature.
by Phil for Humanity