Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Monday, October 17, 2016

GitHub with me.


How to work in GitHub
  • Go to your top, or click "create new repository" after you sign up.







Sunday, October 2, 2016

From Git to GitHub.


Create Folders in GitHub
  1. When upload files, pull the whole directory to the area.
  2. Add "dir/" in front of files to be committed.
  3. Use "git add folder/filename" or "git add file_path" and then "git commit" and "git push"
  4. In GitHub, click "Create new files", in the file name box, add "path_name / file_name"

Clone GitHub Repository
# git clone github_url local_directory
1. git clone https://github.com/changanna/java.git local_java_dir
2. git clong git@github.com:changanna/java.git # SSH protocol
3. git add file_path
4. git add .
5. git commit
6. git push

Check in Folders/Files For First Time
1.git init
2.git config user.name "someone"
3.git config user.email "someone@someplace.com"
4.git add *
5.git commit -m "some init msg"
6.git push
Check in Folders/Files Settings
1. using sourcetree: 
   Repository -> Repository Settings --> Advanced --> uncheck "Use global user settings" box

2. Repository > Repository Settings > Edit config file.
   Check if the [user] section exists. If the user section is missing, add it.

   [user]
   name = "your name"
   email = "your email"

3. Don't use "git pull" to skip settings
   % git fetch
   % git reset --hard origin/master
   % git fetch && git reset --hard HEAD


Git Quick Guides


Saturday, October 1, 2016

Git 101.

Basics:
  • help / man 
    • man git
    • man git-log / man git-commit
    • git help log
  • git config --global user.name <your_name>
  • git config --global user.email you@yourdomain.com
  • git config --get remote.origin.ur /home/amy/project
  • git config -l # 
  • git init
  • git status
  • git log (more)
  • git add <filename> (more)
  • git commit -m "message" <filename> (more)
  • git branch <branch_name> (more)
  • git checkout master 
  • git checkout -b <branch_name>
  • git branch (check branch is created)
  • git merge (more)
  • git branch -d <branch-to-delete> # but git ensure the changes is in current branch
  • git branch -D <branch-to-remove> # no changes are reserved
  • git branch -r origin/master # keeps a pristine copy of original branch
  • git revert (more)
  • git clone <directory> <new cloned directory>
    • git commit -a # to commit the new cloned directory in repository
  • ex: git clone amy.org:/home/amy/project  my_repo_directory # ssh protocol
  • git pull <new cloned directory>
    • git fetch <new cloned directory> # to inspect new changes and decide whether to merge
    • git log -p HEAD..FETCH_HEAD
    • gitk HEAD..FETCH_HEAD
    • gitk HEAD...FETCH_HEAD  # show everything reachable from either one but not both
  • git remote add <new directory> <from directory>
    • git fetch <new directory> # inspect without merging
    • git log -p master..new_directory/master # show a list of changes
    • git merge new_directory/master
  • git pull . remotes/new_directory/master # same as above commands, merge without checking
  • git pull # update all changes to local files
  • git push # update files in remote github repository
  • git show <commit number>
  • git show HEAD # tip of current branch
    • git show HEAD^    # parent
    • git show HEAD^^  # grandparent
  • git show experiment1 # tip of experiment1 branch
  • more...
    • git rm [-n][-q][-r] <dir to be removed>
    • git tag v2.5 <your own commit name.
    • git diff v2.5 HEAD
    • git branch new_branch v2.5
    • git reset --hard HEAD^
    • git grep "key_word" v2.5
    • git log v2.5..v2.7
    • git log --since="2 days ago"
    • git log v2.5..  Makefile
    • git log master .. child # commit in child but not master
    • gitk --since="2 days ago"  codec/
    • git diff  v2.5:Makefile  HEAD:Makefile.in
    • git show v2.5:Makefile
  • git docs
  • git tutorial files

EXAMPLE
% tar xzf project.tar.gz
% cd project
% git init
% git add .
% git commit
% git add file1 file2
% git diff --cached
% git status
% git commit -a -m "new changes"
% git log -p
% git log --stat --summary
% git branch experiment1
% git branch
% git checkout experiment1
    ... (edit files)
% git commit -a
% git checkout master
    ... (edit files)
% git commit -a
% git merge experiment1
% git diff
% git commit -a
% (git push to update files in remote github repository)
% git branch -d experiment1
% git branch -D crazy-idea-to-remove

GitHub:
  • git remote add origin https://github.com/myaccount/mynewrepository.git
  • git push -u origin master_branch_name
  • git hash object - use hash code as an identifier for a specific commit
  • git revert <has code number> - to backtrack
  • git pull origin master_branch_name - get most recent changes to local computer