DEV Community

Eric Lindstrom
Eric Lindstrom

Posted on

Git Work Flow and Divergence

I started my first github repo this week, connected with visual studio, committing changes to feature branches, and merging pull requests into 'main'.

I'm bad at seeing code typos immediately after I do a pull request, correcting them too quickly, and inadvertently editing the code in main without pulling it current first. Then I stumble through how to resolve the terminal errors. It's scary to mess that up and then have github automatically edit (delete!) my local code. Whenever that happens, I'm using "git merge origin/main" to clear out the errors. Is that reasonable?

I'm also bad at naming my commits and pull requests in a useful way. The naming seems tedious. Does anyone use automation to auto-generate names and descriptions?

Top comments (2)

Collapse
 
maxfindel profile image
Max F. Findel

It's not common for a git merge or git pull to delete your local code automatically. It either fails because there are uncommitted local changes or some committed changes turn into a "conflict" 🧨

My recommendation would be to always do a git pull origin main when standing on your main branch and then creating a new feature branch with git checkout -b feat/new-feature 😄

Then after you commit some changes on your feature branch, you can always pull the latest changes from the main branch with another git pull origin main. Always test that your new code works together with your newly pulled main branch code. Finally you can push your newly tested code to Github with git push origin feature/new-feature to review it and merge it using the Github's web interface to spot any unwanted changes or potential new mistakes 👍

Collapse
 
emanoj profile image
Manoj Kumar

Regarding Commit naming:

  1. I keep it simple to 3 words at the most.
  2. I write it like, "Fix homepage", "Push style files", "First Commit" etc. You can read about writing in the imperative here.
  3. FreeCodeCamp has a detailed article on this topic if you are interested.

Hope this helps!