Create new Repo on GitHub:
1.Go to your GitHub account and on the header ,click on "+" icon ,Then click on New repository.
2. Provide your new Repo name ,Select the public option if you want to show your work with every one.
If you want to show the content in repo to specific users ,then select private.
Then click on create repository button at the bottom.
3. Once repository is created, we are navigated to repo dashboard page.
4. Create a sample README file by clicking on below text in screenshot.
Then go down and click on commit change button.
COMMANDS:
1. git init: As a first step we need to create a local empty repo.
2. git clone: First time when we want to get the code from GitHub repo, we use clone command.
Go to your GitHub repo you want to clone and copy the SSH link.
Then use git clone [link copied from above].
3. git branch a : This commands will display all branches present for that GitHub repo.
Before that, once you cloned the latest code you can move into folder ,created with your repo name using - cd folder name
4. git branch --show-current: Useful to check on which branch you are working.
5. Add file to local repo and check the status is git status command
Here untracked file are nothing but created for first time but not pushed to staging state.
6. Use git add . or git add [filepath] to track the files which are newly added or updated.git add . : If you want to push all the code to repo at once we can use this command.
git add [filepath] : When you want to push only specific files instead of files ,we can use this command.
7. Git commit : To save the files and you want to push them to GitHub repo, then we can use command as below.
8. Git push: to transfer your code from local repo to GitHub repo, we use PUSH command.
9. you can see the changes are updated in GitHub repo.
10. Update the read me file from GitHub repo as below and then commit the code.
11. Then go to your local repository to get the latest code. Use git pull command to get get latest code.
You can see the file using CAT command.
12. git log: If we want to check the recent code commit ,then we can use this command.
To check what are updates in the commit ,we can go to GitHub repo you are working on and the navigate to
https://github.com/NAVEENINTEL/devopsDemo/commit/commit-link
Copy and paste the commit-id from above logs and click enter. We can see the changes made on that repo.
Next session will be on Git Branches.....
Comments
Post a Comment