1. Create your project and open that directory , right click and select git bash here
git init |
3. Check your git project status
git status |
Files status :
1. Untracked Files
2. Tracked Files → Modified
→ Staged
→ Un Modified (we can’t see)
4. Add files to git project(add untracked files to project)
git add . |
Let’s check once again git project status
git status |
Here you can see files are in green color , and files now
Files Tracked → Moved to staging area → now files are staged
git add . → add all files in the directory to the git project. If you want to remove some files then you can use below (means you have to unstage means untracked).
5. If you again you added some files in that directory , and to add that files to git project
git status |
Here you can see the newly added file is showing as untracked files that means it is not added to the git project.
4. Once after your changes done to project add that files to git project
git add <filename> |
That new file was added to the staging area.(tracked → staged)
5. Again you want to modify the content of test.html.txt(one of your project file)
You can modify the content in the file and save it , now check git project status
Then we know that, if you modify that file shows as modified(tracked file)
Add that file to git project by using this command
git add <filename> |
Then the file moves to staged area
6. For some reasons you want to remove a files that’s added but you don’t need that , then you can removed from git project
git rm – -cached <file> |
Here you can see that file removed and marked as an untracked file, that means it won’t add that file to the git project.
Mini Summary :
Once after initial git project adding to git , you can again
i) Add new files :
Add files in the project directory , once it is done , come to git bash and run the command git add .
Or you can add specific file by git add <filename>
git add . |
ii) Modify existing files :
You can modify files in the project directory , once it is done , come to git bash and run the command git add . to add files to git project
Or you can add specific file by git add <filename>
git add <filename> |
iii) Remove unwanted files :
To remove unwanted files by running git bash command
git rm – -cached <file> |
7. Finalizing the project committing : means moving to git local repository
git commit -m “test-version v 1.0” |
Above commit is inline commit ,you can add a comment to identify release
We can take this as release versions or comment names on code updation.
8. Uploading local file to remote repository
For this you need to go to github.com and create account and add repository
And copy the repository url : https://github.com/sagar-gith/bootstrap-cards.git
9. Add local repository to github remote repository
→ changing the default branch to main (default branch in git is master, but in gitlab is main), so you need to rename branch before uploading to remote repository in github
git branch -M main |
git remote add origin https://github.com/sagar-gith/bootstrap-cards.git |
→ pushing the project from your local repository to github remote repository
git push -u origin main |
When you’re doing it for the first time it asks for you to authenticate git bash with github, you redirect to github , sign in in the browser and it’s done !
Your project is added to remote github repository , let’s check by refreshing the repository at github
10. Again you can Modify your project and add next commit
Here i modified the project
Added to staging area(git add .) and local repository(git commit -m “test version v 2.0”
Pushed that code to same repository
Here you can see github repository, you can see commit name as test-version v 2.0
This way developer add his code to github repository