s is not always an option as git needs old code in between new lines of code to split it out for you. You’ll want to use either s (get git to split your code into smaller hunks for you) or e (edit your code yourself). This article was very helpful to understand those options. This gives you some options in the Terminal. Check what you have in your working directory git status // Start the process to break down changes in a file git add -patch If it is a new file, it’s a bit more tricky and I’m not going to go through it here as I found it was too much effort. Note to follow these steps, the file must already be committed, i.e. Going through the process has given me the side bonus of learning how to use VIM.īelow are the steps to break down your commit into smaller hunks. In the long term, I think I’ll probably continue using an IDE for staging the changes, but here’s how you do it in Terminal. However in Terminal, it’s a much more manual process. It’s visual and you can highlight the lines really easily. These small parts are called “hunks”.Ĭhoosing which parts to commit in a file is really easy in an IDE like GitHub Desktop or Sourcetree. This means when it comes time to make a commit, I want to commit my changes to a particular file in small parts, not all in one big block. This is because I’m not sure if what I’m doing will work, so I don’t want to commit code that adds no value. When I code, I often play around with the code for quite a while before making a commit. Also a quick keyboard shortcut I use a lot: command + k clears the screen. Merge commits: adjacent and non-adjacentĪnything written means that you should replace everything, including the.Enter a description with your commit message.So I’ve given it a shot whilst I’m learning Go.īelow are some of the standard workflows and terminal commands I find myself using over and over: However I read that git in the terminal is more powerful and worth learning. applications with pretty user interfaces).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |