Victor Adeshile

GIT Common WorkFlow for the everyday developer.

Victor Adeshile's photo
Victor Adeshile

Published on Feb 2, 2021

6 min read

General Procedures for Git for everyday use for Software Developers;

  1. git branch nameOfTheChanges: This would create a new branch with the name “nameOfTheChanges”. The nameOfTheChanges in this context would refer to the name that’s closely related to the changes you want to make in your code. This helps to keep the version control organized both locally and on the Server, like on GitHub.
  2. git checkout nameOfTheChanges: This would make you switch to the branch you created for the purpose of the changes prior to starting to work on the changes. (Now you can head over to make the changes to your code as required and in line with the proposed branch).
  3. git add . or git add *: to add all the changes you’ve made to the branch. This would make a record not only on your local machine like it has already been before, but this time, on the staging area.
  4. git commit -m “A One line Note on Your Changes specific to the branch”: This would help you commit the branch and this time, it is now served and prepared to be pushed to the master origin.(Server).
  5. git status: This helps you know the status of your file version controls both locally and internationally.
  6. git pull origin master: This helps to ensure you pull in the most current changes before pushing the changes you have made yourself locally. A lot of developers who’s never really worked in a team of developers often forget this option because they are used to working alone. It’s a crucial step that helps to ensure that you don’t just push changes to the server that you haven’t registered and merged with the current files you have running locally on your machine.
  7. git push -u origin nameOfTheChanges: This would push the committed changes from the branch that’s just been worked on to the remote repository.
  8. git checkout master: Now that all the necessary previous steps have been taking, it’s time to switch to our master branch.
  9. REPEAT the pull process::: git pull origin master: to ensure every change that’s made without our notice is pulled, and that our working directory is current with what’s on the Server.
  10. git merge nameOfTheChanges: This would merge the branch we have worked on and add this to the master.
  11. git push origin master: This would now push all the changes and everything would be as organized as possible.
  12. git branch -d nameOfTheChanges: This would delete the branch locally. You can do this if the branch is not needed anymore after it has been merged with the master branch on the remote repository.
  13. git push origin -d nameOfTheChanges: This would delete the branch on the remote repository, and help you keep things cleaned out and well structured and organized.

It’s always a good practice to create a branch for the desired feature. Whenever you have a new feature or function to add to your code, create a branch for it in Git before embarking on the changes, This is a process of many seasoned developers, and you too can become one by applying best practices.

Other Useful Git Syntax:

  1. git diff: This helps you see the differences you’ve made in a snapshot on your git CLI just so, you can see the changes.
  2. git branch or git branch -a: This would generate the list of the branches you have locally on your system.
  3. git branch —merged: This would list all the merged branches. If you don’t find your branch listed here, this means you haven't merged it yet.
  4. Fill in the missing space in the comment section below if I left any that's also really frequently used.

Don’t forget to Pull, before your Merge, and then Push. With this workflow, you would always be concise and always never ruin things on the remote repo.

Good luck and keep coding.

Share this