Reputation: 1219
I used clone
to create a local copy of my repository on GitHub.
I modified a few files. Then I did:
git commit -a
And now I want to save my committed changes to the GitHub repository.
How can I do that?
Upvotes: 14
Views: 49634
Reputation: 750
A scenario that's not covered in the question is when branch-protection applies to the original repository. Then, a change to main
or master
is likely to be rejected when you attempt to push. The original question said "clone of my repository" but you're more likely to clone a repository of which you are not the original owner.
If you have updated a protected branch like main
and the subsequent push attempt has been rejected, you need to rename your branch. You can choose a branch name that isn't already used and describes the changes that you made.
Branches can be renamed using git branch -m <branch name>.
Then, you should be able to push successfully using git push
.
Upvotes: 0
Reputation: 1
If you want to commit your changes of the code/ project into github use the below codes in your terminal.
Upvotes: 0
Reputation: 1183
Follow this steps:
1. cd /project path
2. git add *
3. git commit -m "Enter commit message here"
4. git push
Upvotes: 12
Reputation: 2810
To publish your local changes follow the 3 simple steps below:
git add <filename>
or git add *
to add everythinggit commit -m "Enter e message here"
git push
Upvotes: 2
Reputation: 81813
You push your changes:
git push origin master
Replace master
with the name of the branch you want to push, if different from master.
In case the branch was updated since your last update, the changes may be rejected. In that case you have to pull the latest changes on the remote branch first:
git pull origin master
Optionally, you can rebase your changes on top of the remote master (this will prevent a merge commit), by using:
git pull origin master --rebase
Upvotes: 21
Reputation: 3386
You want to push your changes to the central repo with git push
. It might prompt you for your github password.
Upvotes: 3