

#Git add remote and init code
If your local code is modified in the same line of code as the code in the remote repository then you will get a merge conflict. To solve this either commit your local changes first OR use a technique called stash. It's not going overwrite your local changes first. If you have any uncommitted changes in your current working directory and you are trying to pull down from remote then the operation will fail. git pull - to pull the changes from the remote repository (if you have not used the -u flag which pushing).git pull - to pull the changes from the remote repository (if you have used the -u flag which pushing).Simpler way of mergin remote and local repos. The simplest is the Fast Forward strategy. There are different strategies of merging two branches. Merging the remote/main branch into the main branch will result in syncing local repo with remote repo. This will create a remote/main branch in the local repo. Fetch the remote repo and merge the two branches. You want to use the -u flag when remote repo is final source of truthĭifficult way to merge remote and local repos. This allows us to use git pull command to pull from the remote repository without requiring additional arguments. git push -u - u flag to set origin repo to the upstream remote in the git config file.git push - to push the changes to the remote repository with a branch name.


git remote - to see the list of remote repositories you have access to.Popular services are Github, Bitbucket and Gitlab. Git is popular option to collaborate with other developers. git commit -a -m "message" - to commit all files to the staging area with a message.git commit -a - to commit all files to the staging area.To omit using the git add command to add files to the staging area use the -a flag in git commit to directly add files to the staging area. git commit -amend -m "message" - to amend the last commit with a message.git commit -amend - to amend the last commit.git commit -m "message" - to commit with a message.Every commit has an unique id which is used to identify the commit and compare the changes with other commits. moving them from the staging area to the repo, you need to use the git commit command. It's useful for ignoring temporary files and other files that you don't want to commit. This is a file that tells git which files to ignore. It's useful to know the current status of your repo. git reset - to remove a file from the staging area.to remove all files from the staging area git add - adds a single file to the staging area.In order to take a snapshot/commit of the current state of the repo, you need to add all the files you want to commit to the staging area. git init - to create a git repo in another directory.git init - creates a new git repo in the current directory.You can create a git repo in another directory by passing the directory as an argument to the git init command. This is the first step in creating a git repo. git config -global user.email "Your Email" - this is the email that will be used when you commit.git config -global user.name "Your Name" - to set your name.You can do this by adding your name and email to the git config. In order to collaborate with other developers, you need to identify your git identity.

