- Install github
sudo apt-get install git
- Cofig github
git config --global user.name "user_name" git config --global user.email "email_id"
- Create local repository
git init "repo_name" cd "repo_name"
- Create README file
gedit README, write something
- Index file/add file to the staging area
git add README
- Remove files
git rm file_name # remove file_name from local and repo git rm --cached file_name # remove file_name from repo ONLY
- Check repo status
git status
- Commit changes
git commit -m "note"
- Create a repo at github.com
- Connect to the created repo
git remote add origin https://github.com/user_name/repo_name.git
- Upload/push local files to the github repo
git push -u origin master
- Pull down changes
git pull origin master
- Check differeces
git diff
- Create a new branch
git branch branch_name
- Delete branch
git branch -d branch_name
- Switch branch
git checkout branch_name
- Merge branch
git branch des_branch # switch to destination branch (the branch to be merged) git merge src_branch # merge (des_branch will be a copy of src_branch)
- Skip enter user and pw every pushing
$ git config credential.helper store $ git push http://example.com/repo.git Username: <type your username> Password: <type your password>
dntai / github_learning Goto Github PK
View Code? Open in Web Editor NEWLearning GitHub