Skip to content

Instantly share code, notes, and snippets.

@eramella
Last active February 21, 2018 03:29
Show Gist options
  • Save eramella/cf115b53543df58fdc9be30e9b6ca7d2 to your computer and use it in GitHub Desktop.
Save eramella/cf115b53543df58fdc9be30e9b6ca7d2 to your computer and use it in GitHub Desktop.
As a reminder and to learn Git
1) git branch -d <branch_name>
2) git checkout -b <branch name>
3) git show-branch
4) git add --all
5) git push -u origin <branchName>
6) git fetch origin
7) git push origin --delete <branch name>
8) Add remote Github repo to local exisitng:
git remote add origin <remote repository URL>
# Sets the new remote
git remote -v
# Verifies the new remote URL
git push origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin
9) git push --set-upstream origin <branch name> or better: git branch -u origin/<branch name>
10) Undo a commit and redo:
$ git commit -m "Something terribly misguided" (1)
$ git reset HEAD~ (2)
<< edit files as necessary >> (3)
$ git add ... (4)
$ git commit -c ORIG_HEAD (5)
11) git rm -r --cached .vs/
@eramella
Copy link
Author

eramella commented Dec 11, 2016

Git Commands

  1. After deleting a branch on Github (i.e. after confirmed pul request, merged and delete branch) you need to delete local branch as well
  2. Create new branch and go to it (checkout) locally
  3. Shows the local active branches
  4. Stages all latest change (this is needed before commit)
  5. Pushes a new local branch to remote repo (GitHub)
  6. This to be used when merge pull request in Github and want to see and pull merged code into your local repo
  7. Delete remote branch
  8. Publish new repo to newly created Github repo
  9. Fix the branch when it is missing the upstream or/and links the local repo with the remote for push
  10. As noted this let you reset and update the last commit. The -c ORIG_HEAD let you change the commit message if you would like
  11. When folders or files are added to .gitignore but already part of source control, you need to clear the cache

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