This content originally appeared on HackerNoon and was authored by Caio Teixeira
When Should One Commit Code?
Every time you have a small feature working you should commit.
How to Commit Tour Code??
- There are two ways to commit your code:
- When you start working on your feature branch, update your project with the latest changes with the command below:
git pull origin master
\
- As you work on your feature branch, keep updating your project with the command above. Once you are done, create a feature branch using the command below:
git checkout -b feature-branch
\
- Stage your changes, and push your code with the commands below:
git add .
git commit -m "Describe your changes here"
(optional to make sure is clean) git status
git push origin feature-branch
\
- Once you do this, create a pull request on the code repository you are using (Github or Gitlab) and merge your code.
\
- Another way to work with git is by using the following steps:
- When you start working on your feature branch, update your project with the latest changes with the command below:
git pull origin master
\
- Create a feature branch using the command below:
git checkout -b feature-branch
\
- Once you are done, save your changes using the commands below:
git add .
git commit -m "Describe your changes here"
\
- Return to your master branch, and update it using the following commands:
git checkout master
git pull origin master
\
- Return to your feature branch, and merge the master to your feature branch using the command below:
git checkout feature-branch
git merge master
\
- At this point, there might be conflicts to be resolved. After they are resolved, commit again and push your code.
git add .
git commit -m "Merge master"
git push origin feature-branch
\
- Once you do this, create a pull request on the code repository you are using (Github or Gitlab) and merge your code.
\ Happy coding!
\
This content originally appeared on HackerNoon and was authored by Caio Teixeira
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.
APA
MLA
Caio Teixeira | Sciencx (2024-07-14T12:00:12+00:00) How to Use Git Like a Boss. Retrieved from https://www.scien.cx/2024/07/14/how-to-use-git-like-a-boss/
" » How to Use Git Like a Boss." Caio Teixeira | Sciencx - Sunday July 14, 2024, https://www.scien.cx/2024/07/14/how-to-use-git-like-a-boss/
HARVARDCaio Teixeira | Sciencx Sunday July 14, 2024 » How to Use Git Like a Boss., viewed ,<https://www.scien.cx/2024/07/14/how-to-use-git-like-a-boss/>
VANCOUVERCaio Teixeira | Sciencx - » How to Use Git Like a Boss. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/14/how-to-use-git-like-a-boss/
CHICAGO" » How to Use Git Like a Boss." Caio Teixeira | Sciencx - Accessed . https://www.scien.cx/2024/07/14/how-to-use-git-like-a-boss/
IEEE" » How to Use Git Like a Boss." Caio Teixeira | Sciencx [Online]. Available: https://www.scien.cx/2024/07/14/how-to-use-git-like-a-boss/. [Accessed: ]
rf:citation » How to Use Git Like a Boss | Caio Teixeira | Sciencx | https://www.scien.cx/2024/07/14/how-to-use-git-like-a-boss/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.