Notes from the youtube video.
- git add : adds files to staging area
- git commit -m “message” : commits staged files with message
- git add . : add all untracked files
- git add *.[extension] : add all files of this extension
- git commit -am “message” : adds any changes to currently tracked files and commits with message. Won’t add any currently untracked files.
To have files ignored, create a .gitignore file. This can contain extensions (eg. *.log) or file names you want excluded. This gitignore file should be tracked as well.
- git branch [branch name] : creates new branch
- git checkout [branch name] : accesses branch
- git checkout master : main branch
To merge, must be on destination branch.
- git merge : merges branches. must be on destination branch.
In Merge Conflicts
- <<<<< HEAD : shows version in the current branch.
- ======= : separates the two differences
- >>>>>> master: shows version in the source
- add & commit once merge conflicts have been resolved.
- Consider getting a mergetool
- Normally switching branches after adding a file in one branch makes the new file ‘disappear’.
- But if changes aren’t committed before branches are changed, the uncommitted changes will follow (so changes you aren’t ready to commit yet)
- git add [un-committed file] : first track the file
- git stash : will show no more pending changes
- git stash apply : re apply changes from the stash.
- git remote : shows the remote access to the git.
- git remove -v : shows remote access url
- git fetch origin : fetch any changes made to origin since you last checked. Changes will not be merged into work; needs to be done manually.
- git pull origin : fetches and merges automatically.
- git push origin master : push to origin location into master branch.
- git remote add [name of remote] [url of remote] : add new remote access