next thing would be to commit using and then push to what ever branch you want to push
git commit -m 'Some message about the change'
git push origin 'branch-name'
Answer from Shani on Stack Overflownext thing would be to commit using and then push to what ever branch you want to push
git commit -m 'Some message about the change'
git push origin 'branch-name'
Turns out it is that simple:
cd /Users/mainuser/Desktop/YourFolder
git add -A .
git commit -m 'commit message from terminal'
git push
Edit: if you use just git commit without -m, you will enter some editor to type commit message, which I don't know how to quit.
Building off of @Gavin's answer:
Making lazygit a function instead of an alias allows you to pass it an argument. I have added the following to my .bashrc (or .bash_profile if Mac):
function lazygit() {
git add .
git commit -a -m "$1"
git push
}
This allows you to provide a commit message, such as
lazygit "My commit msg"
You could of course beef this up even more by accepting even more arguments, such as which remote place to push to, or which branch.
I ended up adding an alias to my .gitconfig file:
[alias]
cmp = "!f() { git add -A && git commit -m \"$@\" && git push; }; f"
Usage: git cmp "Long commit message goes here"
Adds all files, then uses the comment for the commit message and pushes it up to origin.
I think it's a better solution because you have control over what the commit message is.
The alias can be also defined from command line, this adds it to your .gitconfig:
git config --global alias.cmp '!f() { git add -A && git commit -m "$@" && git push; }; f'
Pushing to GitHub via the terminal
how to commit and push using cli ?
Do you add commit push after you push?
Whats the purpose of a git commit VS git push?
Videos
Hey, I’m a new software developer looking to build a portfolio. When pushing to GitHub via the terminal, am I supposed to push the root folder of my project onto the repository? Or is it specific files or sub folders? Are there any best practices for having a presentable repository? And lastly, what do I add in the ReadMe file?