Member-only story

The Git Commands I Use Every Day

1. Get all latest changes without merging

Stop pulling code that you think will break! Having fetch in your workflow allows you to grab updated code without immediately merging it. Once the code is fetched, you can check it out like any other branch. When you're satisfied, then you can merge.

git fetch --all
# git checkout upstream/some-branch

2. Push upstream regardless of current branch name

Stop typing the branch names especially when they are long branch names. Just tell git you want to push the current branch to a remote location. HEAD is a key word that tells git to use the current branch.

git push upstream head
# git push origin head
# git push github head

3. Label your stash

This is useful if you stash a lot of code and you want to remember what the stash contains at a glance.

git stash save -m "my work in progress"

4. Use a stash from ages ago

Stop undoing stashes with git pop to get to an old stash. You can apply a stash that you created ages ago by using the following command.

# git stash list
git stash apply 3

--

--

Wade Zimmerman πŸ‘¨πŸ»β€πŸ’»
Wade Zimmerman πŸ‘¨πŸ»β€πŸ’»

Written by Wade Zimmerman πŸ‘¨πŸ»β€πŸ’»

I write to vent my frustrations and don’t think much before posting

No responses yet