Skip to content

Instantly share code, notes, and snippets.

@daleyjem
Last active March 17, 2020 02:13
Show Gist options
  • Save daleyjem/0e7697d9c5aa849c2c10 to your computer and use it in GitHub Desktop.
Save daleyjem/0e7697d9c5aa849c2c10 to your computer and use it in GitHub Desktop.
Typical Git Commands

Git commands

Note: Always make sure you're in the project root when doing git commands, or else it won't see the .gitignore file and try to track files that should be ignored.

To reset your files back to the last commit:

git reset --hard HEAD

To create and checkout a new branch:

git checkout -B '[branch name]'

To commit file changes or additions, you first add them to the commit, and then commit them with your message:

git add -A . (don't forget the ending period)

git commit -m "your commit message"

To push up changes:

git push origin develop

If push fails because you're behind, or just to pull down:

git pull origin develop

If any files in 'src' have merge conflicts, go into those files and manually fix what needs fixed.

If any files in 'webroot' have merge conflicts, don't worry about it. Just run a grunt build to overwrite them with new compiled ones from 'src'

When a pull/merge completes without any conflicts, it'll automatically force you into Vim with an autogenerated commit message. Just type colon+W+Q (:WQ). Colon brings up the Vim command prompt... "Write+Quit"

If you successfully fixed a merge conflict, you still have to:

git add -A .

However, an autogenerated merge commit message will be stored in the queue, so you then only have to:

git commit (without the -m "message", because it'll force Vim open, for you to :WQ)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment