I am going to write commands for git integration in system
github is free code hosting platform. where you can even save your private or public code
after installing git in your windows open terminal to configure your credential in git
during code to open your terminal in vscode press ctrl+shift+~
this command is used to check version of git installed in your system
git config --global user.name "give your username in quotation" this is used to configure your username in git
git config --list
list user credentials
git config --global user.email "valid email in quotation"
this is used to add email
git clone url of your code on github
this is used to bring your repository from github to your local sysem. you can even bring anyone's code using link.
git init
make your current working directory a git directory for using git command.
the file will be cloned in same directory where your git is installed open the using ctrl+k+o
git status
show modified files in in working directory, staged for your next commit.
git add filename
stag a file for your next commit, you can use (git add .) without bracket to stage changes in all files
git reset filename
unstage a file while retaining working directory
git diffshows difference of what is changed but not staged
git diff --staged
difference of what is staged but not yet commited
git commit -m "commint messege in quotation"
commit your staged changes with the commit messege
git branch
list your branches. a* will appear next to current active branch.
git branch [branch-name]
create a new branch at the current commit
git checkout [branch-name]
swithch to another branch and check it out into your working directory
git merge [branch]merge the specified branch's history with the current one
git branch -M [new branch name]
used to change the branch name of your current branch
git branch -d [branch name]
used for deleting a branch except your current one.
git diff [branch name]
to compare commits between branches, files and more
An another to method to merge is create pull requst for merge using github. which is used in industries
git log
show all commits in the current branch's history. press q to quit from log
git remote add [alias] [url]used to add an initiated git directory from your local system to a remote system. alias can be anything generally it is origin. url will be from a blank repository created in github.
git remote -v
To verify remote
git fetch [alias]
fetch down all the branches from that git remote
git merge [alias]/[branch]
merge a remote branch into your current branch to bring it up to date
git push [alias] [branch]
transmit local branch commits to the remote repository branch
git push -u [alias] [branch]
-u will save your default alias and branch next you press git push it will take alias and branch without saying.
git pull
fetch and merge any commits from the tracking remote branch you can add alias and branch as well.
git reset [file name]
This command is used to reset from staged but not commited.
git reset HEAD~1
This can be used to go back for 1 commit.
git reset [commit hash]
This will directly move back to that commit. has of commit can be found in log
git reset --hard [commit has]
this will move back to that commit and the code in vs code will also roll back at that commit, while in above the vs code retain it's codes