Skip to content

Instantly share code, notes, and snippets.

@ichbinblau
Last active September 13, 2021 02:55
Show Gist options
  • Select an option

  • Save ichbinblau/8f93bd0b79167e0b2f495ee810b29f78 to your computer and use it in GitHub Desktop.

Select an option

Save ichbinblau/8f93bd0b79167e0b2f495ee810b29f78 to your computer and use it in GitHub Desktop.
git commands
# Commit code for the first time
git init
git remote add origin https://github.com/ichbinblau/tfrecord_generator.git
git add .
git cm -s "initial commit"
git push origin master
# Checkout code
git clone https://github.com/otcshare/smarthome-web-portal
git checkout <branch_name>
git branch #check the current branch
# Commit Code:
git add <changes to checkin>
git commit -m "<comments>" -s
git pull # get the latest update and merge the conflicts
git push # provide your github credentials
# Git sync with upstream
git remote add upstream https://github.com/01org/SmartHome-Demo.git
git remote -v
git fetch upstream
git checkout master
git rebase upstream/master
From <https://help.github.com/articles/syncing-a-fork/>
git pull upstream master
git push origin master
From <http://blog.scottlowe.org/2015/01/27/using-fork-branch-git-workflow/>
# Git merge several commits as one
git reset HEAD^^^^ --soft # revert the last 4 commits
git add .
git cm "" -s
git push --force
# Git delete a branch:
git branch -D [name_of_your_new_branch]
git push origin :[name_of_your_new_branch]
git fetch upstream
# Git create new branch
git checkout -b [name_of_your_new_branch]
git push origin [name_of_your_new_branch]
# Append updates to the last commit
git commit --amend
git push --force
# Checkout a pull request
git fetch upstream pull/ID/head:BRANCHNAME
git checkout BRANCHNAME
From <https://help.github.com/articles/checking-out-pull-requests-locally/>
git push –f origin +http_format:environmental_sensor
# Delete remote branch
git push origin --delete <your_branch>
# Revert local commit
git reset HEAD~N
# Export last N commit as a single patch
git format-patch -3 --stdout > multi_commit.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment