- git init - initiate empty git repository (Local)
- git status - show Untracked files and status
- git add <filename.extention> - add to repo (staging) one stage at once
- git add . - add all changed files
- git add *.html - add files only with html
- git commit -m 'firstCommit' - commit with a msg
- git log - show details commit history
git push - pushes the changes to the remote repository.- git branch NewBranch - allows work in a copy of the code in a mainline without affecting to it
- git checkout NewBranch - switch to new branch
- git merge NewBranch - adding the branch into the mainstream. (You should be in main/wanted branch
- git stash - allow switching to another branch without committing (storing dirty states to future use in stack of unfinished changes)
- git stash apply - re-apply previous changes
- git remote - view list of existing remote repositories
- git clone https.... - pulls down entire repository
- git remote -v -show repo urls
- git remote add Myrepo https.. - add more repositories
- git push origin master - push our changes to the remote repository
- git pull <remote> - get changed data from remote repository
Common Questions
Difference between git add and git commit
Git add adds the modified files to the queue to be committed later. Git add adds files to the Git index, which is a staging area for objects prepared to be committed. Add tells git to start tracking a file.
Git commit commits the files that have been added and creates a new revision with a log. If you do not add any files, git will not commit anything. You can combine both actions with git commit -a. Git commit commits the files in the index to the repository, git commit -a is a shortcut to add all the modified tracked files to the index first. Commit commits your current changes to your local repository.
To ignore some files to adding to the repository
Create .gitignore -> touch .gitignore
inside of it type what are the files you don't want to add -> ex- *.log
However, you need to add git ignore to the repository :)
git merge tools for easy conflict resolution -> ex WinMerge
0 Comments