'How to commit code for a second time on terminal [closed]
I have committed a code into my branch, no one has written anything in it. Do I just git add then git commit -m '' and then git push as usual or do I need to do something else?
Solution 1:[1]
To commit code for the second time you just run:
git add .
That will stage all the changes you made including new files. Then commit these changes:
git commit -m "your message for this commit"
And finally push them using:
**git push --set-upstream origin master**
Note: git push shows error "fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
"
Note that you can run git status
command to display the state of your working directory.
Solution 2:[2]
You seem that you want to be sure what are you going to push to the distant branch before doing it. One way of doing it could be:
Fetch the changes from your remote repository to update your local repository:
git fetch
Display the commits that are not pushed yet to your distant branch, generally
origin/branch_name
:git log origin/branch_name..
Once you're happy with your changes, push them to your distant branch:
git push
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | AElMehdi |