1. How to Push and commit.
1. clone the repository to any folder:
git clone <copied url>
2. if you have already cloned (some days before) and want to take the latest code in your local:
git pull
3. if you have added some code in your local folder and want to push that to Github:
1. git status: gives the status of a tracked file. i..e. which is pushed to GitHub, which are modified and which are untracked (new)
2. git add <filename> (if you want to push a specific file) (this moves the file to staging area)
3. git add . (if you want to push all the changes, here '.' represents all the files)
4. git commit -m "msg you want to type" (this command move the file to the local .git)
5. git push origin <branch name> (this command moves the file to GitHub) (origin is alias name of git URL)
6. git remote add origin <URL of git repo> ( to add origin. now onwards origin is an alias of GitHub URL)
-------------------------------------------------------------------------
How to create a new repository:
1. click on create a new repository in Github and create
2. in the gitbash go to respective folder and type --- git init (this will create .git folder in your local)
3. git add <filename>
4. git commit -m "your comment"
5. git remote add origin <URL of git repo>
6. git push origin <branch name>
----------------------------------------------------------------------------------------
create new branch:
1. to create branch from github website click on branch and type branch name which you want to create. in github you have to create a new branch from some old branch so that source file of old branch will be automatically there in the new branch
2. for creating it through gitbash: git branch <branch name>
by this way, you create the new branch but don't switch to this branch
3. for switching it to a new branch.
git checkout <branch name>
4. for creating and switching it to the new branch
git checkout -b <branch name>
5. renaming the branch
git branch -m <oldname> <new name>
6. renaming the current branch
git branch -m <new name>
No comments:
Post a Comment