by foobarbaz33 · 3y ago · 0 comments
Deeper understanding of git can happen gradually. For now he just needs to be able to do a basic workflow.
################################
# download a new project to local disk
cd ~/projects
git clone someUrl
################################
# get latest code
git pull
################################
# observe the general state of things.
# Run status liberally, before/after any git operation.
git status
################################
# commit changes and push them up the the server.
# This is the bread an butter of your git usage.
git add .
git commit
# good idea to pull in the latest changes before you push up.
git pull
git push
################################
# resolve merge conflicts after a pull
git pull
# alert merge conflicts! git status will tell you which files conflict.
git status
# edit each file with conflicts. Conflicts are flagged in file with ">>>>"
# replace the ">>>>" sections with the final resolved code.
# now check them in and push up the the server.
git add .
git commit
git push
################################
# develop in a feature branch
git checkout -b featureX
# make changes like nomral. add, commit your changes.
# if this is a private branch on your local box only, you do not push.
git add .
git commit
# periodically pull in the code from the parent branch so you don't drift apart
git fetch origin
git rebase origin/master
# feature complete. Merge feature back to master.
git checkout master
git pull # get latest master code
git merge featureX
git pushTelling someone to take a course or go through a tutorial or read a book doesn't help that much, actually it is more discouraging and give impressions of an unhelpful colleague, as a new guy. Depending on GUI or Built-in IDE git features are not the solution, getting to know simple raw native git commands for tasks at hand or problem being faced is the best approach, imo.