Git-Commands 🤞
Problems That I encountered :
Mostly the problems that I encountered while learning git are not real problems rather I would say that they are mistakes that I did because of my half knowledge of what I was trying to do . And I hope any new beginner does not do this mistake again , so read the blog to get wise from my mistakes .
1st mistake : Tried to push files from a different local repo(A_repo) to a remote repo(B_repo). Which is not possible as far as I know . So you can push files from local -> B_Repo to remote->B_Repo only ; that is when you have cloned the remote->B-Repo to your computer i.e, Local->B_Repo.
I tried directly pushing the Local->B_Repo to remote->B_Repo , that is a mistake, because :-
Should check if the remote->B_Repo's branch(in which you are trying to push) is already updated and the Local->B_Repo which you are trying to push is actually pre dated or older update . Soupdate your Local->B_Repo using :
git pull --no-rebase origin main
It will update the Local->B_Repo
I tried out of curiosity , so the Local->B_Repo is updated w.r.t remote->B_Repo now if we commit in local repo , then it is 1 commit ahead right? So if then I try to push it gave me this :-
Everything up-to-date
Not correct so I learned a command to check the status of local->B_Repo in comparison to remote->B_Repo :
git status /or git status -uno
-This helped me to see the status as :
So next to push this changes i did the below followed things :
At last when I saw my remote repo i saw the changes .
Commands I used :
git rebase main
git remote -v
| Push a branch to your remote repository |
| Delete a branch |
git branch [branch name] | Create a new branch |
git branch -a | List all branches (local and remote) |
| Remove a file (or folder) |
| Commit changes |
| List branches (the asterisk denotes the current branch) |
| Add all new and changed files to the staging area |
| Add a file to the staging area |
git status | Check status |
| Initialize a local Git repository |
| Create a local copy of a remote repository |
git pull --no-rebase origin main
git add .
-r : to see the remote branches
-a: see local +remote branches
*: current active.
| Merge a branch into a target branch |
| Merge a branch into the active branch |
| Switch to the branch last checked out |
| Switch to a branch |
What I Learned :
All the above are my exploration learnings .
I learned how to read solutions from stack overflow atleast I have started to read sometimes there are too many solutions and get confused in between choosing which one is the proper solution to execute.
Next I learned to command prompt more efficiently and various linux + git cmmds
Starting to understand what it is like to ask the correct technical questions and optimize the need of optimized prompt engineering .
Got to know what are the uses of various git commands .
How to write a blog on the real time problem simultaneously solving it .
Subscribe to my newsletter
Read articles from aryan ingle directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by