How(and why) to commit.

Commiting is an important topic in web development. But a lot of beginners are curious: What should I commit? and how often should i commit? or how to commit?
The answer is simple. You should commit everything, every small chage you did – you commit.
B…


This content originally appeared on DEV Community and was authored by JustKooba

Commiting is an important topic in web development. But a lot of beginners are curious: What should I commit? and how often should i commit? or how to commit?
The answer is simple. You should commit everything, every small chage you did - you commit.
But why?
Imagine you're working on a project 8 hours a day, you've just finished your work and then all your files got corrupted. You've lost all your work! But not if you commit everything - thats why.
To commit our work we use Git.

When should I start using git?
Most of developers say:

You should learn git after javascript

But in my opinion: You should start either after css or as you start learning js.

How do I get git?
it's easy! just download git on your pc from here.

How to use git?

If you want to start using git in your current project you have to use the command git init. after that your local git repository is active and running. The next step is to connect to a remote repository on Github, to accomplish that you firstly need to create a github repository and then connect to it. use the command git remote add origin [link to your repository].
Now your git repo is connected to your github repo.

How to commit?
Let's say you've just finished some changes. To commit them use the commands below:

git add .
git commit -m "[your commit message]"
git push -u origin

note: if you get this error mesage(error: failed to push some refs to [repo]
hint: Updates were rejected because the remote contains work that you do
) after git push, use the command git push -f origin to forcefully push your work on the Github repo.

after that you can refresh your github and your files will be there!

Thank you for reading. Happy coding!


This content originally appeared on DEV Community and was authored by JustKooba


Print Share Comment Cite Upload Translate Updates
APA

JustKooba | Sciencx (2023-04-02T19:28:09+00:00) How(and why) to commit.. Retrieved from https://www.scien.cx/2023/04/02/howand-why-to-commit/

MLA
" » How(and why) to commit.." JustKooba | Sciencx - Sunday April 2, 2023, https://www.scien.cx/2023/04/02/howand-why-to-commit/
HARVARD
JustKooba | Sciencx Sunday April 2, 2023 » How(and why) to commit.., viewed ,<https://www.scien.cx/2023/04/02/howand-why-to-commit/>
VANCOUVER
JustKooba | Sciencx - » How(and why) to commit.. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/04/02/howand-why-to-commit/
CHICAGO
" » How(and why) to commit.." JustKooba | Sciencx - Accessed . https://www.scien.cx/2023/04/02/howand-why-to-commit/
IEEE
" » How(and why) to commit.." JustKooba | Sciencx [Online]. Available: https://www.scien.cx/2023/04/02/howand-why-to-commit/. [Accessed: ]
rf:citation
» How(and why) to commit. | JustKooba | Sciencx | https://www.scien.cx/2023/04/02/howand-why-to-commit/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.