Skip to content

Instantly share code, notes, and snippets.

@ucaiado
Last active June 15, 2016 15:35
Show Gist options
  • Save ucaiado/28ae61cbac939e3b7ff9 to your computer and use it in GitHub Desktop.
Save ucaiado/28ae61cbac939e3b7ff9 to your computer and use it in GitHub Desktop.
GIT

GIT - COMMAND LINE

Very useful lnks

nice udacity concept map

https://www.udacity.com/wiki/w/image/view?key=agpzfnVkYWNpdHl1chYLEglXaWtpSW1hZ2UYgIDgioaL4goM

linking linux to github

-set-up-git -generating-ssh-keys -fork-a-repo

tutorials

-how to use GitHub

-switching-branches-without-committing

-git-guide

installation: https://www.udacity.com/wiki/ud775/install-git

sublime: https://www.udacity.com/wiki/ud775/sublime

setting up git workspace: https://www.udacity.com/course/viewer#!/c-ud775/l-2980038599/m-2955818665

about bare repositories: http://www.saintsjd.com/2011/01/what-is-a-bare-git-repository/

cloning Repos

git clone https://github.com/YOUR-USERNAME/Spoon-Knife

check your configuration

git config --list

SSH from hell

https://help.github.com/articles/caching-your-github-password-in-git
ssh-agent bash
ssh-add
[ENTER YOUR PASSPHRASE...or not]

creating local folder and linking to git

mkdir <projectname> #CRIA DIRETORIO PARA GUARDAR DADOS DO GIT
cd <projectname>
git init #INICIA GIT NO DIRETORIO
git remote add origin [email protected]:codexico/tutorial-github.git #CLONA REPOSITORIO EXISTENTE
git clone -b <branch> <remote_repo>
git pull origin [BRANCH NAME] # BAIXA DADOS

source: http://stackoverflow.com/questions/4114095/revert-to-a-previous-git-commit

####Temporarily switch to a different commit git checkout -b old-state [ID_git]

####Undo published commits with new commits # This will create three separate revert commits: git revert 0766c053 25eee4ca a867b4af

# It also takes ranges. This will revert the last two commits:
git revert HEAD~2..HEAD	
	
# To get just one, you could use `rebase -i` to squash them afterwards
# Or, you could do it manually (be sure to do this at top level of the repo)
# get your index and work tree into the desired state, without changing HEAD:
git checkout 0d1d7fc32 .
	
# Then commit. Be sure and write a good message describing what you just did
git commit	

source: Udacity and other

To Commit

git checkout -b [branch name] --> cria e muda para outro branch
git checkout [branch name] --> mudar para outro branch
git add . ou
git add [arquivo]
git commit -m "<MENSAGEM SOBRE ALTERACAO>"
git push origin [branch]

git fetch origin->>atualiza projeto local

To check if there is somethngto commit

git status

check the stats of the last commits

git log --stat

or git log -n 1 -->> show the newest log

####To see the changes made bvefore and after a branche was created git log --graph --oneline master [branch]

To add colors to the diff

git config --global color.ui auto.

init and clone repositories from Dropbox

https://gist.github.com/trey/2722927

  1. on project folder in your DropBox:

    git init --bare ".git"

  2. on your "local" git folder:

    git clone C:/Path To your DropBox/and/your/project/.git touch README.md git add . git commit -m "Initial commit" git push origin master

  3. Obs: To render github markdown files offline, use:

source: http://stackoverflow.com/questions/9843609/view-md-file-offline

pip install grip

To check differences between commits in the command line

git diff [id alteracao 1] [id alteracao 1]
git diff --> Para qualquer diferença
git diff --staged -->Para ver as diferenças que estão na stage area
                     para serem comitadas
show commit_id --> Comparing a commit to its parent

To remove a file from the staging area, but keep it in your working directory

git reset [filename]
git reset --hard -->To discard any changes in your staging area

To get a file in stage out the command have to be [optional]

git rm --cached [filename]

To come back to the newest commit after came back to a old one

git checkout master

Merging Files

  1. If happens any problem when you try to merge, to revert back:

    git merge --abort

  2. Merge branches

    git merge [branch 1] [branch 2]

  3. After merging, you don't need the brach anymore, then:

    git branch -d [branch1] (d of delete)

  4. After some conflict was resolved, you have to add to the stage

    git add [filename]

To insert something on github

git remote add origin [git url] 

!!origin is a standard name to your remote repository

To check if I already done this

git remote

or git remote -v (for verbose)

To push my changes

git push [my remote] [my branch]
git push origin master

To Clone from github just type:

git clone [github url]

To see all your branches

git branch -a

About licenses

http://www.addalicense.com

Think about

add CONTRIBUTING.md

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