· Chuck Conway · Software Development  · 1 min read

Git Cheat Sheet

Below are git commands I find myself using over and over.

Below are git commands I find myself using over and over.

Below are git commands I find myself using over and over.

Clone repository

git clone https://github.com/tinymce/tinymce-dist.git

Add existing git files to remote git repo

cd /path/to/my/repo
git remote add origin https://[email protected]/lostinkali/flightstats.git
git push -u origin --all # pushes up the repo and its refs for the first time
git push -u origin --tags # pushes up any tags

Create a repository in existing folder

git init
git add .
# Adds the files in the local repository and stages them for commit
git commit -m "Initial commit"

Change current branch to master

git checkout better_branch
git merge --strategy=ours master # keep the content of this branch, but record a merge
git checkout master
git merge better_branch

Delete Branch

git branch -D bugfix

Revert to previous commit

git checkout master
git reset --hard e3f1e37
git push --force origin master
# Then to prove it (it won't print any diff)
git diff master..origin/master

adds the file to git.

git add [filename]

kills off the untracked files since the more recent commit in the log.

git clean -fd

commits the added files to git.

git commit -m "enter message here"

Remove the file git. Use -f to force the file to removed even when there are changes.

git rm file1.txt

Tagging a specific point in time.

git tag -a v1.4 -m 'my version 1.4'
Back to Blog

Related Posts

View All Posts »
Give a Safe Space to Express Ideas

Give a Safe Space to Express Ideas

When leading a team, it’s important to create an environment where everyone feels safe to express their ideas regardless of their experience level.

Scrum is Overrated

Scrum is Overrated

Scrum is overrated. It's a good starting point for teams that have never worked together, but it's not the end all be all.

The Benefits of Using a Build Framework

The Benefits of Using a Build Framework

Continuous Integration (CI) and/or Continuous Delivery (CD) is the norm on software projects these days. There are many build servers such as Azure DevOps, TeamCity, Jenkins, and Cruise Control.Net.