Skip to content

Instantly share code, notes, and snippets.

@ethan-deng
Last active December 8, 2017 03:49
Show Gist options
  • Save ethan-deng/f1da71924dc163ddbb56102fb8ea825c to your computer and use it in GitHub Desktop.
Save ethan-deng/f1da71924dc163ddbb56102fb8ea825c to your computer and use it in GitHub Desktop.

AWS CodeCommit

The git remote command is really just an easier way to pass URLs to these "sharing" commands.

When you clone a repository with git clone, it automatically creates a remote connection called origin pointing back to the cloned repository.

The git fetch command imports commits from a remote repository into your local repo. The resulting commits are stored as remote branches instead of the normal local branches that we’ve been working with. This gives you a chance to review changes before integrating them into your copy of the project.

Difference

git diff myfile.js

git fetch origin
git diff --name-only master origin/master

Force checkout

git checkout -- myfile.js

Force pull

git fetch --all
git reset --hard origin/master
git pull origin master

Pull

git pull origin master
git pull --all

Pull in steps

git fetch origin master
git merge origin/master
git push origin master
git remote add origin ssh://git-codecommit.us-west-2.amazonaws.com/v1/repos/portal

Git

Download Git

https://git-for-windows.github.io/

https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

####1. Set up profile

git config --global user.name "YOUR_USERNAME"
git config --global user.name
git config --global user.email "your_email_address@example.com"
git config --global user.email
git config --global --list

Generate SSH key

ssh-keygen -t rsa -C "your_email_address@example.com"

Must use the same email as in step 1

Copy the SSH key by running this in windows cmd

type %userprofile%\.ssh\id_rsa.pub | clip

####2. Clone a project

git clone https://project_url

####3. Switch to branch

git checkout branchname
git checkout -b branchname //create a new branch and switch to it

####4. Get the changes

git fetch remote-branch-name

####5. Merge master to current branch

git merge master

####6. Pull is same as fetch + merge

git pull origin branch-name

or

git pull --all

####7. Stage changes

git add -A

####8. Commit changes

git commit -m "commit message"

####9. Push changes

git push origin branch-name

###10.

git remote -v

###11. Tagging

git tag -a 1.0 -m "my and portal2 1.0"
git tag
git show 1.0
git push origin 1.0
git checkout -b version1 1.0

https://stackoverflow.com/questions/2007662/rollback-to-an-old-git-commit-in-a-public-repo

git checkout 552d59ba12cfc0373ff365e83dfec7a481312917 .

Dot at the end!!!

fatal: reference is not a tree: do a git pull --all first.

###12. Reset

git reset --hard

Switch between SSH and HTTPS

https://help.github.com/articles/changing-a-remote-s-url/

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